开发者

batch file to check if the specific word "test" exist in the files, IF exist copy the whole folder to another location

How can I check if the word "test" exist in any files inside a folder(that contain tons of folders and files) .. and if exist, copy the whole folder to another location.

Plea开发者_开发知识库se help thank you


findstr /c:"test" *.txt > NUL
if not errorlevel 1 xcopy *.* anotherlocation

If you want to check all files beneath current folder at any level, add /S switch in findstr command. Do the same in xcopy command to copy the whole folder structure.


@echo off 
SETLOCAL ENABLEDELAYEDEXPANSION 
findstr /c:"Finished schedule" E:\Init.log > NUL 
if "!errorlevel!"=="0" 
( echo "OK" )
else ( echo "NOK" )
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜