How to delete a file via the command line

Svetlana
Svetlana
June 27, 2014
10029
How to delete a file via the command line

Most Windows users are accustomed to working with the graphical interface and delete files to the Recycle Bin using the Delete command from the context menu. However, it is possible to do this from the command line. How to delete a file or folder via the command line will be discussed in this article.

Deleting files

You can delete a file from the command line using the "del" command. It is important to specify the full address of the file. For example:

  • del C: \ folder \ file.txt

If the folder or file name contains spaces, enclose the address in quotes, for example:

  • del "C: \ folder 1 \ file 1.txt"

To delete several files from a folder at once with different names, but identical extensions, replace the file name with an asterisk (*). For example:

  • del C: \ folder \ *. txt

To delete several files with the same name, but different extensions, replace the extension with an asterisk. For example:

  • del C: \ folder \ file. *

To remove all files from the folder, replace the name and extension with an asterisk.For example:

  • del C: \ folder \ *

Deleting folders

To remove a folder from the command line, use the “rmdir” command. In this case, you also need to specify the full address of the folder, and if its name contains spaces, enclose this address in quotes. For example:

  • rmdir C: \ folder
  • rmdir "C: \ folder 1 \"

If the folder contains files or other subfolders, you must additionally use the "/ S" parameter, which deletes the folder with all its contents.



Related News:


The memorial ribbon for Radonica
Cover for knife from birch bark
IKEA's new application allows you to visualize furniture in a particular room
Baked Hasselbeck Potatoes with Garlic and Thyme
Learning letters - how to help a child learn them quickly and easily
Horoscope
Money Tree