6

I have a simple batch file that will loop through all *Test.htm files and copy them. Some of the files will contain a string that I don't want to copy.

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

What I want in pseudo code:

@echo off
FOR /R "C:\" %%g IN (*Test.htm) DO ( 
   if %%g contains "Exclude" do nothing
else 
   copy...
)
Endoro
  • 37,015
  • 8
  • 50
  • 63
twifosp
  • 277
  • 2
  • 7
  • 16

1 Answers1

13

For filename:

@echo off

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

For File content:

@echo off

FOR /R "C:\" %%g IN (*Test.htm) DO ( 
   (Type "%%g" | FIND /I "Exclude" 1>NUL) || (
       Copy "%%g"...
   )
)
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417