Windows sometimes can't delete files and folders because the path and name are longer than the allowed 255 characters.
Ways to delete undeletable files and folders
- Try shift-delete in Windows Explorer.
This should normally bypass moving the file or folder to the trash bin.
- Try deleting the file or folder from the command line.
c:\ > del toolongfilename.txt
- Try deleting the file or folder from the Powershell command line.
PS c:\ > remove-item toolongfilename.txt
- Try moving the file to a folder higher up in the folder hierarchy, thus shortening the path/name.
- Use the file manager in eg 7zip to delete the file or folder.
Download it from https://www.7-zip.org.
- Use robocopy to delete the files or folders. Robocopy is preinstalled in all Windows-versions since Vista or so.
Be careful though, files and folders will not go to the trash bin and will not be available for recovery!
The basic idea with using robocopy is to sync a new empty folder to the folder containing the pesky files with too long names.
Using the command line:
c:\ > dir
Directory of c:\delete\this\folder\with\a\very\long\name
c:\ > md c:\emtpynewfolder
c:\ > robocopy c:\emtpynewfolder c:\delete\this\folder\with\a\very\long\name\Loremipsumdolorsitamet,consecteturadipiscingelit.Phaselluseget.Loremipsumdolorsitamet,consecteturadipiscingelit.Phaselluseget.Loremipsumdolorsitamet,consecteturadipiscingelit.Phaselluseget.txt /purge
c:\ > rd c:\emtpynewfolder
The tricks and hints above have have been collected from several sources over the years.