开发者

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

开发者 https://www.devze.com 2023-03-22 18:48 出处:网络
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.

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

精彩评论

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