- Techie Buzz - http://techie-buzz.com -
Recursively Delete Files in Folders and Sub Folders Using Command Prompt
Posted By Keith Dsouza On July 29, 2008 @ 10:11 pm In Tips And Tricks | 5 Comments
“Do you know if there's a way to delete files of a particular filetype from a set of folders quickly in Windows? For example, I've got a folder by the name "ABC" and I've got some pictures and music files there, and I need a tool that automatically deletes all those pictures (i.e., files of a particular format like JPEG) quickly from the ABC folder and its sub-folders.The task of deleting files recursively from folders and sub-folders does not require any tools and can be easily done using the Windows command prompt. For this post we will assume that the directory, you want to delete the files from is “D:ABC” and it contains several sub-folders from which you want to delete the files. Note: Before using the command, we want to warn you that the files will be completely deleted bypassing the recycle bin. If you are looking for a safer way to delete files, we can point you to a earlier post where we introduced the recycle command, using which you can safely delete files to the recycle bin using the command prompt [1], you can also use wildcards to recycle the files.
You can also use wildcards to delete files of only a particular type, the command to delete files recursively based on wildcards will look like:
del /S /P *.jpg
Note: The /P tells the command to prompt the user before deleting the file, we recommend using this with wildcards.
If you want to delete files from only the current directory change the command as below:
del *.jpg
That’s it simple and easy without having to use any additional tools. If you have your own questions don’t forget to ask us [2]. we will always try our best to find a solution for you.Article printed from Techie Buzz: http://techie-buzz.com
URL to article: http://techie-buzz.com/tips-and-tricks/recursively-delete-files-in-folders-and-sub-folders-using-command-prompt.html
URLs in this post:
[1] safely delete files to the recycle bin using the command prompt: http://techie-buzz.com/utilites/recycle-files-from-windows-command-prompt.html
[2] ask us: http://techie-buzz.com/ask-us-tip-us/
Click here to print.
Copyright © 2009Techie Buzz. All rights reserved.