Edited the listing of the path for the location of the .bak files to use
SET @pathension = 'dir /OD /s /b '+@Path+'*.'+@Extension
Allowing for all .bak files in subdirectories and a shorter directory listing format. Just easier when all my .bak files were sitting in their own folders 🙂
Also had to remove the +@path in front of +@migrate in the 'Restoreheaderonly' statement as I was getting multiple '///' when the .bak file location was on the network.
Currently using it to restore 37 databases though, so it works like a charm!
Good job...