user1559948
user1559948

Reputation: 5

Exclude files that start with number - batch script

How to exclude the files from the loop -> if the file name in a directory starts with number.

for %%G in (*.sql) do sqlcmd -S %SName% -U %UName% -P %Pwd% -d %DbName% -Q "EXECUTE sp_deploy %%~nG" >> "C:\%%~nG.sql" 2>&1

I do not want to execute the sql if the file name start with a number. How can I stop that..

Thanks in advance.

Upvotes: 0

Views: 188

Answers (1)

Andomar
Andomar

Reputation: 238256

"if '%%~nG' not like '[0-9]%' EXECUTE sp_deploy %%~nG"

Upvotes: 3

Related Questions