Trending News
Promoted
batch job. append "John Smith" to all text files that don't have "john smith" in it.?
Howto append "Written by John Smith" to all text files on a computer that don't have "Written by John Smith" in it already.
1 Answer
Relevance
- KevinLv 71 decade agoFavorite Answer
Use the "for" command to take the output of "dir" and pipe it through "find" to look for the "Written by John Smith" string. If the 'find' fails to find the string in the file, then echo the string into the file. This is on one line,
for /f "tokens=*" %f in ('dir *.txt /b /s') do find /i "Written by John Smith" "%f" || echo Written by John Smith>>"%f"
Still have questions? Get your answers by asking now.