Deleting File or Folder via Command Prompt!
Deleting file or folder via command prompt on MS Windows desktop and server operating systems is a popular solution to delete!
Every once in a while, due to various reasons, one needs to clean up drive and delete duplicate photos, documents, temporary files, shortcuts, videos or other unnecessary or unused files, folders, documents, etc. via Command Prompt.
1.) Deleting folders via the command prompt!
Deleting the folder without asking whether it should be deleted with the parameter /s /q
C:>rmdir /s /q C:\folder_path\destination_folder
In this example, the directory with the designation "Target_Folder" is not deleted, but all content (files) without a query or deletion confirmation!
del /q /f /s C:\folder_path\destination_folder
About the parameters
/q runs the operation without asking for confirmation,
/f ignores the read-only attribute and forces deletion
/s deletes contents from all subfolders
2.) Delete files via the command prompt!
Basically the same as deleting a folder, the parameters can also be used, unless you want to confirm the deletion every time!
del /q /f /s C:\folder_path\dest_folder\dest_file.txt
3.) Only delete certain files with placeholders using cmd.exe!
In this example, all plain text *.txt files are in the target folder , we use all parameters from the deletion example again, since we are sure that we really want to delete irrevocably!
del /q /f /s C:\folder_path\destination_folder\*.txt
You can also use *.jpg to delete all images, or *.docx to delete all Word documents, and so on! Wildcards are handy for filtering files!
4.) What should be considered when deleting via the command prompt!
Users unfamiliar with MS Windows Desktop and Server operating systems should note that deleting a folder or directory will delete all files and folders within that folder or directory.
Restoring the deleted data is hardly possible, sometimes it makes sense to move the data instead of deleting it, for example to an external drive or USB stick, so that you can only delete it when you are absolutely sure.
5.) Why delete the data via the command prompt?
Sometimes it just makes sense and sometimes it is faster to delete data via the command prompt, especially if you are sure that the data is no longer needed.
You can even do it directly from the File Explorer or Quad Explorer address bar , reducing the risk of accidentally deleting the wrong files in the wrong directory.
cmd /k del /q /f /s *
There is no need to specify the path here if you are in the right folder
| (Image-1) Delete file or folder via the address bar!
6.) More tips for deleting via the command prompt and ... also different!
FAQ 136: Updated on: 26 August 2023 10:59
If you have problems establishing an Internet connection, it can be helpful to delete the connection IPs of the visiting website via the command prompt
Very popular is the easy and fast deactivation of users via command line on MS Windows 11, 10, and MS Server 2022, 2019, operating systems Everyone
Automation batch files for Windows are becoming more and more popular, it is even more important to correctly name and use the batch, which is often referred
The Windows CMD has internal commands that are in the command prompt itself, this does not start another exe that is started separately The external commands
Sometimes you just want a plain example of a subfunction ergo Sub-Routine in a command prompt batch file to understand how it works The CALL command starts
Sometimes you just want to rename JPEG to JPG to keep things in order, you can do that easily from the command line on MS Windows Desktop and Server OS
The classic search in files for a character string via the command prompt is hardly used anymore, but it is still available on Windows 11, 10, In order
»» My question is not there in the FAQ
Keywords: windows, console, deleting, file, folder, command, prompt, desktop, server, operating, systems, popular, solution, delete, every, once, while, Questions, Answers, Software