1.

Solve : Dos command to move files that contain a particular word from source to target?

Answer»

I need to move files from source to target folder that contain in the file text a particular word, (not file name)

Give a try and change for your SETTINGS the variables keyWord, SourceFolder, TargetFolder and if you found that correct for your case, just omit the echo command before the command move
Code: [Select]echo off
Title Move files that contain a particular word from source to target
Set "KeyWord=New"
Set "SourceFolder=%userprofile%\desktop"
Set "TargetFolder=C:\NewFolder"
If not EXIST "%TargetFolder%" MD "%TargetFolder%"
for /f "delims=" %%f in ('Dir /b /s "%SourceFolder%\*.txt"') do (
find /I "%KeyWord%" "%%f" >nul 2>&1 && ( echo move /y "%%f" "%TargetFolder%" )
)
pauseNicely done, and happy to give it whirl after failing with my archaic ATTEMPTS
Thank you and will report back.



Discussion

No Comment Found