 |
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows 7. The Windows 7 forum also covers news and updates and has an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.
Windows 7 - File - Delete from Command Prompt File - Delete from Command Prompt How to Delete a File from the Command Prompt
Published by Brink
01-16-2010
| File - Delete from Command Prompt How to Delete a File from the Command Prompt  Information This will show you how to permanently delete a File using the DEL or ERASE command from within a command prompt. This can be handy if you cannot delete the file normally.  Note While you can run this command in a non-elevated or elevated command prompt, you would get the best results using a elevated command prompt.  Warning The file will be deleted immediately and not placed in the Recycle Bin first. EXAMPLE: DEL and ERASE Command NOTE: You can use either the DEL or ERASE command in the command prompt. They are the same command. Here's How:1. Do step 2, 3, or 4 for how you would like to delete your file(s). 2. To Use a Elevated Command Prompt in Windows NOTE: This will allow you to delete any file(s) on the computer.A) Open Folder Options, uncheck the Hide extensions for known file types box, and click on OK. (see screenshot below) B) Open a Elevated command prompt.
C) Go to step 5. 3. To Use a Command Prompt in Windows NOTE: This will only allow you to delete any file(s) in your user folders.A) Open Folder Options, uncheck the Hide extensions for known file types box, and click on OK. (see screenshot below) B) Open a command prompt.
C) Go to step 5. 4. To Use a Command Prompt at Boot NOTE: This will allow you to delete any file(s) on the computer.A) Open a command prompt at boot.
B) In the command prompt, type diskpart and press Enter. (see screenshot below)
C) In the command prompt, type list volume and press Enter. (see screenshot below) NOTE: This will let you see what the drive letter is for the drive that you want to delete the file in since it may not always be the same drive letter that it is in Windows.
D) After making note of the drive letter, type exit and press Enter. (see screenshot below) E) Go to step 5. 5. Do step 6, 7, 8, 9, or 10 for how you would like to delete your file(s). 6. To Delete a Specific File in Command PromptA) In the command prompt, type the command below and press enter. NOTE: Substitute Full Path of File with extension within quotes below with your files's full path and name with the extension included within quotes instead. Code: DEL /F /S /Q /A "Full Path of File with extension" NOTE: For example, if I wanted to delete a text file named File with the file extension .txt on my desktop, I would type this command below. Code: DEL /F /S /Q /A "C:\Users\UserName\Desktop\File.txt" B) Go to step 11. 7. To Delete All Files in a Folder without Confirmation in Command Prompt NOTE: This will not ask you if it's ok (Y/N) to delete each file when deleting all files in a folder and the folder's subfolders.A) In the command prompt, type the command below and press enter. NOTE: Substitute Full Path of Folder within quotes below with the full path of the folder that you want to delete all files in. Code: DEL /F /S /Q /A "Full Path of Folder\*" NOTE: For example, if I wanted to delete all files in my D:\Projects folder and subfolders, I would type this command below. Code: DEL /F /S /Q /A "D:\Projects\*" B) Go to step 11. 8. To Delete All Files in a Folder with Confirmation in Command Prompt NOTE: This will ask you if it's ok (Y/N) to delete each file when deleting all files in a folder and the folder's subfolders.A) In the command prompt, type the command below and press enter. NOTE: Substitute Full Path of Folder within quotes below with the full path of the folder that you want to delete all files in. Code: DEL /P /F /S /A "Full Path of Folder\*" NOTE: For example, if I wanted to delete all files in my D:\Projects folder and subfolders, I would type this command below. Code: DEL /P /F /S /A "D:\Projects\*" B) Go to step 11. 9. To Delete All Files with a Specified File Extension in a Folder without Confirmation in Command Prompt NOTE: This will not ask you if it's ok (Y/N) to delete each file when deleting all files with a specified file extension in a folder and the folder's subfolders.A) In the command prompt, type the command below and press enter. NOTE: Substitute Full Path of Folder within quotes below with the full path of the folder that you want to delete all files in. Substitute extension with the file extension of the type of files that you want to delete in the folder and it's subfolders. Code: DEL /F /S /Q /A "Full Path of Folder\*.extension" NOTE: For example, if I wanted to delete all txt (text) files in my D:\Projects folder and subfolders, I would type this command below. Code: DEL /F /S /Q /A "D:\Projects\*.txt" B) Go to step 11. 10. To Delete All Files with a Specified File Extension in a Folder with Confirmation in Command Prompt NOTE: This will ask you if it's ok (Y/N) to delete each file when deleting all files with a specified file extension in a folder and the folder's subfolders.A) In the command prompt, type the command below and press enter. NOTE: Substitute Full Path of Folder within quotes below with the full path of the folder that you want to delete all files in. Substitute extension with the file extension of the type of files that you want to delete in the folder and it's subfolders. Code: DEL /P /F /S /A "Full Path of Folder\*.extension" NOTE: For example, if I wanted to delete all txt (text) files in my D:\Projects folder and subfolders, I would type this command below. Code: DEL /P /F /S /A "D:\Projects\*.txt" 11. The file(s) should now be deleted. 12. Close the command prompt. NOTE: If you used a command prompt at boot, then also close the System Recovery Options window and restart the computer. That's it,
Shawn |  Published by | | Administrator Join Date: Oct 2008 Location: Texas Posts: 37,303 | |
 Tutorial Tools | | | | | | | | | |
01-31-2010
|
#1 | | |
Hi Shawn, nice tutorial. But could you please explain why we need the /F /Q /A command?
What does it stand for?
| My System Specs | | System Manufacturer/Model Number Compaq OS Windows 7 Ultimate x64 CPU Intel core 2 duo T 5550 @ 1.83 GHz Motherboard Intel 965 express mobile chipset Memory 3 GB DR 2 @ 667 MHz Graphics Card Onboard with approx 512 MB RAM Sound Card Onboard Monitor(s) Displays 15"4 inch widescreen Hard Drives 160 GB SATA WD. Internet Speed sucks |
01-31-2010
|
#2 | | Windows 7 Ultimate x64 SP1 |
Hello Dinesh,
You can see a list and complete explanation of the switches in the example screenshot, but it's just to cover all bases to help make sure that the file is deleted.
/F Force deleting of read-only files.
/Q Quiet mode, do not ask if ok to delete
/A Allows file with set attributes (ex: hidden files) to be deleted | My System Specs | | System Manufacturer/Model Number Self built custom OS Windows 7 Ultimate x64 SP1 CPU Intel i7-980X 3.3 Ghz (3.48 Ghz OC'd) Motherboard ASUS P6X58D Premium Memory 12 GB (2GBx6) DDR3 PC3-16000 2000 MHz Kingston HyperX Graphics Card Sapphire HD5870 Eyefinity 6 2GB Sound Card Realtek HD Audio ALC889 Integrated Chip Monitor(s) Displays 3x 27" Asus VE278Q Screen Resolution 1920x1080 Keyboard Logitech Cordless Desktop MX 5500 Revolution Mouse Logitech Cordless Desktop MX 5500 Revolution PSU OCZ Series Gold OCZZ1000M 1000W Case Corsair Obsidian 800D Cooling Thermalright Ultra 120 Extreme Copper CPU heat sink w/120 MM Hard Drives 160GB OCZ RevoDrive X2
** 2 x 1TB Samsung HDD HD154UI SATA Internet Speed 50 Mb/s Download and 2 Mb/s Upload Other Info Microsoft LifeCam Cinema
** Lite-On iHBS212 12x BD Writer
** Samsung CLX-3175FW Printer
** Netgear WNDR3800 Router
** Motorola SBG6580 Cable Modem
** 2x APC Back-UPS XS 1500 |
01-31-2010
|
#3 | | |
Oh that's nice. Thanks. | My System Specs | | System Manufacturer/Model Number Compaq OS Windows 7 Ultimate x64 CPU Intel core 2 duo T 5550 @ 1.83 GHz Motherboard Intel 965 express mobile chipset Memory 3 GB DR 2 @ 667 MHz Graphics Card Onboard with approx 512 MB RAM Sound Card Onboard Monitor(s) Displays 15"4 inch widescreen Hard Drives 160 GB SATA WD. Internet Speed sucks |
01-31-2010
|
#4 | | Windows 7 Ultimate x64 SP1 |
You're welcome. | My System Specs | | System Manufacturer/Model Number Self built custom OS Windows 7 Ultimate x64 SP1 CPU Intel i7-980X 3.3 Ghz (3.48 Ghz OC'd) Motherboard ASUS P6X58D Premium Memory 12 GB (2GBx6) DDR3 PC3-16000 2000 MHz Kingston HyperX Graphics Card Sapphire HD5870 Eyefinity 6 2GB Sound Card Realtek HD Audio ALC889 Integrated Chip Monitor(s) Displays 3x 27" Asus VE278Q Screen Resolution 1920x1080 Keyboard Logitech Cordless Desktop MX 5500 Revolution Mouse Logitech Cordless Desktop MX 5500 Revolution PSU OCZ Series Gold OCZZ1000M 1000W Case Corsair Obsidian 800D Cooling Thermalright Ultra 120 Extreme Copper CPU heat sink w/120 MM Hard Drives 160GB OCZ RevoDrive X2
** 2 x 1TB Samsung HDD HD154UI SATA Internet Speed 50 Mb/s Download and 2 Mb/s Upload Other Info Microsoft LifeCam Cinema
** Lite-On iHBS212 12x BD Writer
** Samsung CLX-3175FW Printer
** Netgear WNDR3800 Router
** Motorola SBG6580 Cable Modem
** 2x APC Back-UPS XS 1500 |
05-12-2011
|
#5 | | Windows 7 Ultimate x64 SP1 |
Updated to include more options. | My System Specs | | System Manufacturer/Model Number Self built custom OS Windows 7 Ultimate x64 SP1 CPU Intel i7-980X 3.3 Ghz (3.48 Ghz OC'd) Motherboard ASUS P6X58D Premium Memory 12 GB (2GBx6) DDR3 PC3-16000 2000 MHz Kingston HyperX Graphics Card Sapphire HD5870 Eyefinity 6 2GB Sound Card Realtek HD Audio ALC889 Integrated Chip Monitor(s) Displays 3x 27" Asus VE278Q Screen Resolution 1920x1080 Keyboard Logitech Cordless Desktop MX 5500 Revolution Mouse Logitech Cordless Desktop MX 5500 Revolution PSU OCZ Series Gold OCZZ1000M 1000W Case Corsair Obsidian 800D Cooling Thermalright Ultra 120 Extreme Copper CPU heat sink w/120 MM Hard Drives 160GB OCZ RevoDrive X2
** 2 x 1TB Samsung HDD HD154UI SATA Internet Speed 50 Mb/s Download and 2 Mb/s Upload Other Info Microsoft LifeCam Cinema
** Lite-On iHBS212 12x BD Writer
** Samsung CLX-3175FW Printer
** Netgear WNDR3800 Router
** Motorola SBG6580 Cable Modem
** 2x APC Back-UPS XS 1500 File - Delete from Command Prompt problems? All times are GMT -5. The time now is 02:45 AM. |  |