6

我有一个简单的批处理文件,它将遍历所有 *Test.htm 文件并复制它们。一些文件将包含我不想复制的字符串。

FOR /R "C:\" %%g IN (*Test.htm) DO  (
echo %%g
)

我想要的伪代码:

@echo off
FOR /R "C:\" %%g IN (*Test.htm) DO ( 
   if %%g contains "Exclude" do nothing
else 
   copy...
)
4

1 回答 1

13

对于文件名:

@echo off

FOR /R "C:\" %%g IN (*Test.htm) DO ( 
   (Echo "%%g" | FIND /I "Exclude" 1>NUL) || (
       Copy "%%g"...
   )
)

对于文件内容:

@echo off

FOR /R "C:\" %%g IN (*Test.htm) DO ( 
   (Type "%%g" | FIND /I "Exclude" 1>NUL) || (
       Copy "%%g"...
   )
)
于 2013-04-24T14:17:26.810 回答