Restore without specifying location for each file I am working with a database that has a dynamic filegroup structure. The number of filegroups and filegroup files can and do change.

Is there a way to specify one data and one log folder in a script that will restore all files to those folders?
Is there a way to specify one data and one log folder in a script that will restore all files to those folders?


You just have to use a good existing tool (hint : restoregene). It does take care of multiple filegroups dynamically.

dont put all the filegroups in one folder - as if the drive fails, you loose your entire database. The whole point of having filegroups is to have them on different disks/LUNs.

EDIT: Based on your comment 


  The purpose of the restore script is to restore a copy of the production database to QA and CI servers.


PowerShell is the way to go - Start-SqlServerMigration.ps1

Basically, you have to use WITH MOVE option in restore command since the disk and folder layouts wont match from PROD to QA or other servers.