Batch For loop excludes file name containing

I have a simple batch file that will scroll through all the * Test.htm files and copy them. Some of the files will contain a string that I do not 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... ) 
+4
source share
1 answer

For file name:

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

For file contents:

 @echo off FOR /R "C:\" %%g IN (*Test.htm) DO ( (Type "%%g" | FIND /I "Exclude" 1>NUL) || ( Copy "%%g"... ) ) 
+10
source

All Articles