Force delete files with a rather large name
Use the Microsoft tool robocopy.exe
.
- Create a new empty folder, e.g.
c:\empty
Then copy that empty folder onto the folder which contains the long filenames which you're trying to delete, e.g.
c:\myannoyingfolder
. Do this like so in the command prompt:robocopy /MIR c:\empty c:\myannoyingfolder
okay, let's say you want to delete a tree D:\very\long\path
, you don't necessarily need to use any tools such as Robocopy.
- Go to the root directory of the drive which contains the directory which you can't delete
- Create a directory with a single letter name, eg
D:\a
- Navigate to inside the directory that you want to delete, in this
case
D:\very\long\path
- Select all (Ctrl+A) and Cut (Ctrl-X)
- Navigate to the folder you just created
- Paste (Ctrl-V)
- Now, move up to the root directory and delete the temp folder, in this case
D:\a
- Then go back and delete the original directory
You can integrate this functionality into the windows shell. My enhancement to Flo's answer was too long for a comment.
I added a Delete
command to the Windows context menu.
The delete.reg
file adds registry entries to associate folders with the robodelete.bat
batch file.
delete.reg
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\Delete]
[HKEY_CLASSES_ROOT\Directory\shell\Delete\command]
"Extended"=""
@="\"D:\\Documents\\robodelete.bat\" \"%1\""
robodelete.bat
mkdir c:\empty
robocopy /MIR c:\empty %1
rmdir %1
rmdir c:\empty
Note: You may need to change the paths in both files as per your preferences.
WARNING: There is no way to undo this command. It does not use the recycle bin and does not ask Y/N to confirm before destroying the folder for good!