answersLogoWhite

0


Best Answer

No need for a batch file, the following commands will do it:

CD folder

FOR /F %i IN (files.txt) DO DEL %i /P /F /S

The CD command sets the current folder. All deletions will occur in the specified folder and its sub-folders.

The files.txt file must be a list of file names (wildcards permitted) with one file name per line. If this file does not reside in the current folder you must specify the fully-qualified path or the relative path (relative to the current folder).

The FOR loop essentially executes the DEL command for each file in files.txt. The DEL command line switches are:

/P (prompt for confirmation before deleting each file)

/F (force delete read-only files)

/S (recurse through sub-folders of the current folder).

To suppress prompting, remove /P but add /Q (quiet mode) to suppress prompting on global wildcards. For more help on this, enter DEL /? at the command prompt. For more help on the FOr command, type FOR /? at the command prompt.

If used in a command script (.cmd) or batch file (.bat), replace %i with %%i. The only real advantage of using a batch file (other than to save a bit of typing) is that you can also pass the root folder and the file containing your file list as parameters (identified by %1, %2, etc).

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do I write a batch file to search recursive folders for a list of partial file names with wildcards and then delete the files?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What happen if you delete Microsoft office folders after uninstall it?

Generally, no harm will result if you delete Microsoft Office folders after uninstalling the applications. Make sure that no important files like documents are in the folders before deleting.


If you uninstall Bearshare will it delete your files?

Bearshare downloads files to folders outside its program folders and does not delete either completed downloads or partially downloaded files when it is uninstalled.


How do you delete personal folders on Yahoo mail?

just exit out of it and it should delete right away.


Where is the place you put files and folders you want to delete or get rid of?

trash =) or shift+delete


How do you delete items in the spam folders?

Spam is the same thing as a junk folder so you might want to delete the


What is the place to put files and folders you want to delete or get rid of?

Recycle bin


What is the name of the computer virus that prompts to delete folders when opened?

Trojan Goat


Should I delete the folders of contentie5?

If you hit the ALT key and under tools, click on Folder options, under view, uncheck:Hide Protected Operating System FilesGo to the transparent files and delete select all the files inside to delete.Do NOT Delete the Folders or Other Files Besides These!


Can you delete the hidden folders in windows?

Yes, you can but you have to be careful because hidden folders are usually required for the operating system. But you are sure that you can delete it safely, follow instructions. First, to delete a hidden folder you should have an administrator-type account, it's required. Second, hidden folders should be visible. To make them visible you have to choose in the explorer window: My Computer->Tools->Folder Options...-> tab "View". In the advanced settings list box choose Show hidden files and folders. Sometimes your account is not the folder/file owner the system will not allow you to delete it. In this case you have to take ownership of the folder/file and allow your account to have full access to the required files/folders.


How do you get rid of Minecraft?

Delete the .minecraft folder in your AppData folder and delete any shortcuts you have placed (on your desktop, in any other folders that you keep games).


How do you delete folders off of your iPod Touch?

You drag all of the apps inside out out the folder and then it disappears.


How do I hide a hotmail folder that I created?

You put your cursor over the Folders button and a wheel thing shows up so you click on that and it will show all your folders so you click on whatever folder you want to delete and push okay. That's how you delete a folder.