我想从我的批处理文件中排除2个或更多文件。
我的批处理文件执行该文件夹中的所有SQL文件。
代码如下:
ECHO %USERNAME% started the batch process at %TIME% >output.txt
FOR %%G IN (*.sql) DO (
//IF would go here to skip unwanted files
sqlcmd.exe -S RMSDEV7 -E -d ChaseDataMedia7 -i "%%G" >>output.txt
)
pause那么,我如何在循环中添加并跳过我不想执行的文件呢?
发布于 2012-01-13 19:10:20
你可以链接IFs;
FOR %%G IN (*.sql) DO (
if not %%G==foo.sql if not %%G==bar.sql (
some command "%%G"
)
)发布于 2012-01-14 11:13:05
@echo off
setlocal EnableDelayedExpansion
set unwantedFiles=foo bar baz
for %%g in (*.sql) do (
set "test=!unwantedFiles:%%~Ng=!"
if "!test!" == "!unwantedFiles!" (
echo %%~Ng.sql is not unwanted, process it:
echo Process with %%g
)
)获取一个名称,并通过删除当前名称来复制unwantedFiles。如果结果与之前相同,则此名称不在unwantedFiles中,因此请处理它...
https://stackoverflow.com/questions/8849425
复制相似问题