Today we’ll see how we can move files that contain a particular word, a specific directory/subdirectories, recursively. Sometimes we may need to move files that meet a certain pattern to a particular folder.
For example, imagine that we have a directory/subdirectories with thousands of audio files, with metadata in the filename and we want to make an automatic selection of all the audio files that contain the word SALES in the name tag. We could go directory to directory looking for the word SALES and cutting and pasting in a folder or we could use the Windows search and give us the results, but sure that the following command can be more than useful.
FOR /R "C:\AUDIO_DIRECTORY\" %%G IN (*SALES*.mp3) DO move "%%G" "C:\SALES_AUDIO\"
Copy this code, save it in a bat file and run it. It will automatically dump all mp3 audio files containing the word SALES in the C:\SALES_AUDIO\ folder.
From here we can apply this small code to any example you can think of.
I hope it will help you;)