# Using a Batch Script to Move Specific Files with Specific File Contents

I am looking to find a file with the contents 'Radiac' in one particular folder and then move all those files to a another folder.

For example: I have might have 3 identical file-names with different extensions like below. Let's say, the content Radiac is only in the jones.pdf file. What I want is a batch script that finds this specific content and then moves all the 3 file-names? I hope that makes sense. I'm new to windows batch scripting.

jones.pdf
jones.xml
jones.txt


How can I do this?

• I think you would be better off with powerscript, python, or perl for this. You will also need to find a library or tool that can spit raw text out of a pdf. PDF is a specific format, not just text. This will be almost impossible to do with just batch. Seems like a stack overflow question to me. – Eddie Dunn Nov 30 '15 at 21:03
• Hi Eddie, Thanks for the response. In this case, the .pdf document is searchable. However, to simplify things lets say it is the jones.txt file instead of the jones.pdf file. What I am looking to do is find the filename with this specific content then xcopy this filename.*.* and its associated extensions to another folder. – JohnNg Nov 30 '15 at 21:19
• @B.Ng filename.*.* do you really mean this (It doesn't match your example filenames)? Or do you mean filename.*? – DavidPostill Dec 1 '15 at 9:20

for /f "delims=" %%a in ('findstr /m /c:"Radiac" *') do xcopy "%%~na.*" "C:\path\to\your\folder"