- Windows delete all files with name
- Syntax
- Parameters
- Remarks
- Examples
- del del
- Синтаксис Syntax
- Параметры Parameters
- Комментарии Remarks
- Примеры Examples
- A quick way to delete all files with a certain name pattern in Windows
- Using Command Prompt
- Using Windows PowerShell
- How To Delete Files & Folders – From The Windows Command Line (CMD, DOS)
- Jump Right In:
- Navigating To The File Using CMD.
- Deleting Folders / Directories Using CMD.
- Deleting Files Using CMD.
- Creating a dummy file with a specific size.
- Delete Many Files Or Folders At Once.
- Delete Files Or Folders From Any Directory.
- What We’ll Learn:
- Navigating To The File Using CMD:
- Deleting Folders / Directories Using CMD
- Deleting Files Using CMD
- Delete Many Files Or Folders At Once — From CMD
- Delete Files Or Folders From Any Directory (CMD)
- Summary:
- That’s It!
Windows delete all files with name
Deletes one or more files. This command performs the same actions as the erase command.
The del command can also run from the Windows Recovery Console, using different parameters. For more information, see Windows Recovery Environment (WinRE).
If you use del to delete a file from your disk, you can’t retrieve it.
Syntax
Parameters
Parameter | Description |
---|---|
Specifies a list of one or more files or directories. Wildcards may be used to delete multiple files. If a directory is specified, all files within the directory will be deleted. | |
/p | Prompts for confirmation before deleting the specified file. |
/f | Forces deletion of read-only files. |
/s | Deletes specified files from the current directory and all subdirectories. Displays the names of the files as they are being deleted. |
/q | Specifies quiet mode. You are not prompted for delete confirmation. |
/a[:] | Deletes files based on the following file attributes:
. |
/? | Displays help at the command prompt. |
Remarks
If you use the del /p command, you’ll see the following message:
FileName, Delete (Y/N)?
To confirm the deletion, press Y. To cancel the deletion and to display the next file name (if you specified a group of files), press N. To stop the del command, press CTRL+C.
If you disable command extension, the /s parameter will display the names of any files that weren’t found ,instead of displaying the names of files that are being deleted.
If you specify specific folders in the parameter, all of the included files will also be deleted. For example, if you want to delete all of the files in the \work folder, type:
You can use wildcards (* and ?) to delete more than one file at a time. However, to avoid deleting files unintentionally, you should use wildcards cautiously. For example, if you type the following command:
The del command displays the following prompt:
Are you sure (Y/N)?
To delete all of the files in the current directory, press Y and then press ENTER. To cancel the deletion, press N and then press ENTER.
Before you use wildcard characters with the del command, use the same wildcard characters with the dir command to list all the files that will be deleted.
Examples
To delete all the files in a folder named Test on drive C, type either of the following:
To delete all files with the .bat file name extension from the current directory, type:
To delete all read-only files in the current directory, type:
del del
Удаляет один или несколько файлов. Deletes one or more files. Эта команда выполняет те же действия, что и команда Erase . This command performs the same actions as the erase command.
Команда Del также может запускаться из консоли восстановления Windows с использованием различных параметров. The del command can also run from the Windows Recovery Console, using different parameters. Дополнительные сведения см. в разделе Среда восстановления Windows (WinRE). For more information, see Windows Recovery Environment (WinRE).
Если удалить файл с диска с помощью Del , вы не сможете получить его. If you use del to delete a file from your disk, you can’t retrieve it.
Синтаксис Syntax
Параметры Parameters
Параметр Parameter | Описание Description |
---|---|
Указывает список из одного или нескольких файлов или каталогов. Specifies a list of one or more files or directories. Для удаления нескольких файлов можно использовать подстановочные знаки. Wildcards may be used to delete multiple files. Если указан каталог, все файлы в каталоге будут удалены. If a directory is specified, all files within the directory will be deleted. | |
/p /p | Запрашивает подтверждение перед удалением указанного файла. Prompts for confirmation before deleting the specified file. |
/f /f | Принудительное удаление файлов, которые доступны только для чтения. Forces deletion of read-only files. |
/s /s | Удаляет указанные файлы из текущего каталога и всех подкаталогов. Deletes specified files from the current directory and all subdirectories. Отображает имена файлов при их удалении. Displays the names of the files as they are being deleted. |
/q /q | Задает тихий режим. Specifies quiet mode. Подтверждение удаления не запрашивается. You are not prompted for delete confirmation. |
/a [:] /a[:] | Удаляет файлы на основе следующих атрибутов файлов: Deletes files based on the following file attributes:
. . |
/? /? | Отображение справки в командной строке. Displays help at the command prompt. |
Комментарии Remarks
При использовании del /p команды вы увидите следующее сообщение: If you use the del /p command, you’ll see the following message:
FileName, Delete (Y/N)?
Чтобы подтвердить удаление, нажмите клавишу Y. Чтобы отменить удаление и отобразить следующее имя файла (если указана группа файлов), нажмите клавишу N. Чтобы закрыть команду Del , нажмите клавиши CTRL + C. To confirm the deletion, press Y. To cancel the deletion and to display the next file name (if you specified a group of files), press N. To stop the del command, press CTRL+C.
Если вы отключаете расширение команды, параметр /s отображает имена всех файлов, которые не были найдены, а не отображает имена удаляемых файлов. If you disable command extension, the /s parameter will display the names of any files that weren’t found ,instead of displaying the names of files that are being deleted.
Если указать определенные папки в параметре, все включаемые файлы также будут удалены. If you specify specific folders in the parameter, all of the included files will also be deleted. Например, если нужно удалить все файлы в папке \ворк , введите: For example, if you want to delete all of the files in the \work folder, type:
Можно использовать подстановочные знаки (* и ?) для удаления нескольких файлов за раз. You can use wildcards (* and ?) to delete more than one file at a time. Однако во избежание непреднамеренного удаления файлов следует использовать подстановочные знаки с осторожностью. However, to avoid deleting files unintentionally, you should use wildcards cautiously. Например, если ввести следующую команду: For example, if you type the following command:
Команда Del выводит следующее сообщение: The del command displays the following prompt:
Are you sure (Y/N)?
Чтобы удалить все файлы в текущем каталоге, нажмите клавишу Y и нажмите клавишу ВВОД. To delete all of the files in the current directory, press Y and then press ENTER. Чтобы отменить удаление, нажмите клавишу N и нажмите клавишу ВВОД. To cancel the deletion, press N and then press ENTER.
Прежде чем использовать подстановочные знаки с командой Del , используйте те же подстановочные знаки с командой dir , чтобы получить список всех файлов, которые будут удалены. Before you use wildcard characters with the del command, use the same wildcard characters with the dir command to list all the files that will be deleted.
Примеры Examples
Чтобы удалить все файлы в папке с именем Test на диске C, введите следующую команду: To delete all the files in a folder named Test on drive C, type either of the following:
Чтобы удалить все файлы с расширением bat из текущего каталога, введите: To delete all files with the .bat file name extension from the current directory, type:
Чтобы удалить все файлы только для чтения в текущем каталоге, введите: To delete all read-only files in the current directory, type:
A quick way to delete all files with a certain name pattern in Windows
This article introduces a simple way to list and delete all files with a certain name pattern in a folder and all its sub-folders. A common scenario is deleting the hidden thumbs.db files which Windows XP (and in some cases, Windows 7) stores in each folder that contains pictures or video files.
Using Command Prompt
- Open Command Prompt. You’ll find it in Start Menu, Accessories folder.
- Set the active volume to the one on which your intended files reside. To do so, type the volume letter followed by a colon sign (:) and press Enter key.
For example:
C:
Navigate to the folder which you believe to have the files which have the same pattern of name. To so, type cd “folder address“, (where folder addressis the address of the folder to which you’d like to navigate,) and press ENTER key.
For example:
cd «C:\Documents and Settings\test\My Documents»
(Optional) Get a list of all the files which have the same name pattern. This will give you a chance to verify what is deleted before actually deleting them. To do so, type: dirfilename.ext/a /b /s (where filename.extis the name of the files which you’d like to find; wildcards are also acceptable.)
For example:
dir thumbs.db /a /b /s
Delete those files. Type delfilename.ext/a /s (where filename.extis the name of the files which you’d like to delete; wildcards are also acceptable.)
For example:
del thumbs.db /a /s
NOTE: You cannot delete a group of files across more than one volume with only one command. You must repeat this command for each drive.
Using Windows PowerShell
- Start Windows PowerShell. You’ll find it in Start Menu.
- Navigate to the folder which you believe to have the files which have the same pattern of name. To so, type Set-Location ‘folder address‘, (where folder addressis the address of the folder to which you’d like to navigate,) and press
ENTER key.
For example:
Set-Location ‘C:\Documents and Settings\test\My Documents’
(Optional) Get a list of all the files which have the same name pattern. This will give you a chance to verify what is deleted before actually deleting them. To do so, type: Get-ChildItem -includefilename.ext-recurse -force (where filename.extis the name of the files which you’d like to find; wildcards are also acceptable.)
For example:
Get-ChildItem -include thumbs.db -recurse -force
Delete those files. Type Get-ChildItem -includefilename.ext-recurse -force | Remove-Item -force (where filename.extis the name of the files which you’d like to delete; wildcards are also acceptable.)
For example:
Get-ChildItem -include thumbs.db -recurse -force | Remove-Item -force
NOTE: You cannot delete a group of files across more than one volume with only one command. You must repeat this command for each drive.
How To Delete Files & Folders – From The Windows Command Line (CMD, DOS)
Jump Right In:
Navigating To The File Using CMD.
Deleting Folders / Directories Using CMD.
Deleting Files Using CMD.
Creating a dummy file with a specific size.
Delete Many Files Or Folders At Once.
Delete Files Or Folders From Any Directory.
What We’ll Learn:
Welcome!
This guide is all about deleting files and folders from the windows command line.
- We’ll start by learning, how to navigate the file or folder we want to delete form the command prompt.
- How to use the Del and Rmdir commands to remove files and folders respectively.
- How to take advantage of wildcards to perform an operation on multiple files or directories.
- And finally, we’ll learn how to delete files and folders without navigating to the directory in which they are located.
Lets get started!
Navigating To The File Using CMD:
To delete a file or folder using the command prompt we must first navigate to the location of our file.
By default the command line is located at a folder named after your computers username (C:\Users\MyPC). This folder contains your documents, downloads and desktop directories, among others.
To view all the files in this directory use the “Dir” command, which stands for directory.
Every file in this directory will be displayed at once.
If the file or directory you want to delete is located at your desktop for example use the “Cd” command to change the command prompts directory.
Simply type “Cd” followed by the folder you want to navigate into within quotes.
You will at once navigate into the desktop directory and from here you can use the “Dir” command once again to locate the file or folder you want to delete.
If you navigated to the wrong directory by mistake, type:
You will immediately be navigated into the previous directory.
In a similar way you can use a combination of the “Dir” and “Cd” commands to navigate to any directory and locate any file or folder.
Deleting Folders / Directories Using CMD
To delete a folder use the “Rmdir” command, which stands for “Remove Directory”.
Keep in mind that as the name suggests, “Rmdir” only deletes directories. Trying to delete a file using “Rmdir” will constitute in an error.
You might be wondering why we surrounded the name of our folder in quotes. The quotes tell the command line that the spaces separating the words do not constitute an additional parameter and that they are simply a part of the name of our folder.
“Rmdir” without any parameters only removes folders that are empty, to delete a folder along with the files or folders within it you need to use the /S parameter.
The command would look like this:
After entering the command the command line will ask if you are sure you want to delete this file. Simply press “ y ” to confirm.
If you want to delete a folder in a directory other than your users folder you would need to start the command prompt as an administrator. Be careful when deleting folders with administration privileges, the wrong command can very easily break your computer.
Deleting Files Using CMD
The command for deleting files using the cmd is “Del“. Unlike “ Rmdir “, “ Del “can only delete files. Using “ Del ” to delete a folder will constitute in an error .
To delete a file simply type “Del” followed by the name of your file along with its extension in quotes.
Your file should be immediately deleted.
Once again if you file is not located in the users folder or within any of its sub-directories you would need to start the command prompt as an administrator.
Be very careful however , the wrong command in an administrator command prompt can very easily break your computer.
To delete more than one file at once simply enter all the names of your files one after the other.
Delete Many Files Or Folders At Once — From CMD
Entering the name of every file or folder you want to delete is not always practical.
Work smarter not harder.
You can delete every file that begins with a set of characters by using a wildcard.
Wildcards are special symbols that take the place of characters or words.
The most commonly used wildcard is the asterix.
Typing “Del” followed by a set of characters that is shared among the names of the files we want to delete and an asterix, will delete all of them.
Every file that begins with the word “File” will be deleted.
To delete a set of folders instead, simply replace the Del command with Rmdir.
Similarly you can delete only files of a specific type by specifying its extension before a wildcard. With the following command for example, we can delete every text file in our current directory.
We can even delete every file or folder by using a wildcard, all by itself.
Here is an example using the Rmdir command:
Every folder in your current directory will be deleted along with any contents within it.
Be careful when deleting files and folders, the wrong command can easily delete important files and folders.
Delete Files Or Folders From Any Directory (CMD)
While you can use the “Rmdir” and “Del” commands to delete files and folders in your current directory, what if you want to delete a folder or file that’s located in a different directory without having to navigate there yourself?
You would have to enter your command as usual but instead of typing the name of the file or folder you want to delete directly you would have to enter the location of the target directory followed by a backward slash and then name of your folder or file.
It should look something like this:
In the same way you can replace “Rmdir” with any command to complete any task from any directory.
Summary:
- Navigate to the directory the file you want to delete is located with the “CD” and “Dir” commands.
- Use “Rmdir” to delete folders and “Del” to delete files. Don’t forget to surround the name of your folder in quotes if it contains a space.
- Use wildcards to delete many files or folders at once.
That’s It!
You now know how to delete files and folders directly from the command prompt.
If you liked this short guide take a look at a few of our other posts related to the windows command line, or if you really liked it consider enrolling in our video course where you will learn the ins and outs of the Windows command Line.