我们知道这很有效,并且从命令行运行良好......参考。使用具有多种文件类型的 forfiles 进行搜索掩码?
for %G in (fileone, filetwo) do forfiles /P D:\hold\logs /M *.%G.* /C "cmd /c echo @path"
我们想要做的是使用这两个文件掩码:fileone 和 filetwo 来调用另一个 FORFILES 并且加倍的 %%G 现在在批处理脚本中。我想我们可能可以在一度?
SET SOMELOGS=D:\hold\logs
for %%G in (fileone, filetwo) do forfiles /P %SOMELOGS% /M *.%%G.* /C "cmd /c ECHO @path & call :locate @path"
:locate
echo somepath %%1
FOR /f "tokens=1-9 delims=/: " %aa IN ('forfiles /P "%SOMELOGS%" /M %%1 /D -1 /C "cmd /c echo @file @fdate @ftime"') DO call :ZIP %%a %%b %%c %%d %%e %%f %%g
:ZIP
PAUSE
结果是:
"D:\hold\logs\server.fileone.log.2013-12-14.a"
Invalid attempt to call batch label outside of batch script.
"D:\hold\logs\server.fileone.log.2013-12-15.a"
Invalid attempt to call batch label outside of batch script.
"D:\hold\logs\server.fileone.log.2013-12-15.b"
Invalid attempt to call batch label outside of batch script.
"D:\hold\logs\server.fileone.log.2013-12-16.a"
Invalid attempt to call batch label outside of batch script.
这似乎也不起作用..不能多次使用:/c...参考..嵌套的文件:路径和扩展过滤器
SET SOMELOGS=D:\hold\logs
for %%G in (fileone, filetwo) do forfiles /p %SOMELOGS% /m *.%%G.* "forfiles /p @path /M %%1 /D -1 /C "cmd /c echo @file @fdate @ftime"') DO call :ZIP %%a %%b %%c %%d %%e %%f %%g
:ZIP
PAUSE