I need help to create a simple batch script to delete some files on a specific folder and it's sub-folders too. What I need it to do: Go to a folder; In this folder, there are two folders. The script needs to search for dozens of terms, then delete ALL files that match the terms. On Linux, the script would be similar to this: Code: find /home/amarildo \( -name "file1*" -o -name "file2*" -o -name "file3*" \) -print -delete If it makes any difference, this script is intended for Windows 7. Thanks in advance
You can use: Code: del "file1" "file2" "file3" /s >> d:\result.txt It will erase files and store results in txt file. You can also use wildcards for filenames(*, ?).
The script can just change to the folders and then delete with wildcards. My batch scripting abilities are pretty basic but it would be something like this. Code: "cd Folder1 del File1*.*, File2*.* cd.. cd Folder2" del File1*.*, File2*.*"
It should be run from parent directory. With /s switch it will check all subdirs for specified files and delete them, like MisterB explained. If there are more subdir levels in directory structure it will check them all.
My windows scripting is pretty basic. I wasn't aware of the /s switch which is just about the same as the /r switch in Linux. Much simpler than changing directories manually.