I'm trying to write a windows batch file that can delete files from subdirectories. I would rather not hard code the directory structure in, so I can use this process with other projects.
C:\MyProject
,C:\MyProject\?
,Is there a quick del
(of type) function I am simply missing?
CD [Your_Folder] && RMDIR /S /Q . From Windows Command-Line Reference: /S: Deletes a directory tree (the specified directory and all its subdirectories, including all files).
You can delete multiple files or folders by holding down the Ctrl key and clicking each file or folder before pressing Delete . You can hold down the Shift key while pressing the Delete key to prevent files from going to the Recycle Bin when deleted.
The command DEL /F/Q/S *. * > NUL deletes all files in that folder structure, and omits the output which improves the process further. Use cd.. to navigate to the parent folder afterwards. Run the command RMDIR /Q/S foldername to delete the folder and all of its subfolders.
Actually you can use the standard del command:
c:
cd MyProject
del /S *.type
Where type is the extension you want to delete and the /S parameter will check in all subfolders of MyProject.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With