Solved search files in a directory for word, move those with word

May 18, 2012 at 13:33:31
Specs: Windows 7
I need to search all the files in a directory for a word and then move those files that have the word to one directory and all the files without the word to a different directory.

See More: search files in a directory for word, move those with word

Report •


#1
May 19, 2012 at 04:40:14
✔ Best Answer
:: ==========================================
:: 
:: sandi.bat  Sat 19-05-2012 18:17:53.07
@echo off & setLocal enableDELAYedeXpansioN

for /f "tokens=* delims= " %%a in ('dir/b *.txt') do (
find "word" < "%%a" > nul
  if errorlevel 1 (
    echo move "%%a" nope
  ) else (
    echo move "%%a" found
  )
)

::===========================================


=====================================
Life is too important to be taken seriously.

M2


Report •
Related Solutions


Ask Question