Reputation: 6016
I have a directory that contains .sql files like
file.xxx.v3.0.sql
file.xxx.v3.0.sql
file.xxx.v3.0.sql
file.xxx.v3.0.sql
In a .bat file how would I loop through all the files in a directory that start with "file." and end in ".v3.0.sql"?
So far I've got
for /f %%b in ('dir /b /s "%apppath%\files\*.sql"') do call :import %%b
Upvotes: 1
Views: 501
Reputation: 47614
This should work in your case:
for /f %%b in ('dir /b /s "%apppath%\files\file.*.v3.0.sql"') do call :import %%b
You can also use braces like this:
for /f %%b in ('dir /b /s "%apppath%\files\file.*.v3.0.sql"') do (
call :import %%b
...
)
Upvotes: 2
Reputation: 354356
Forego the for /f
route. There be dragons (for Unicode characters and spaces, especially – best not pick up any bad habits).
You can use plain old for
, which can iterate over files just fine:
for %%b in (%apppath%\files\file.*.v3.0.sql) do (
call :import %%b
)
Upvotes: 2