While trying to delete a directory in Windows Explorer, I receive the error “The source file name(s) are larger than is supported by the file system. Try moving to a location which has a shorter path name, or try renaming to shorter name(s) before attempting this operation.”
First I would like to reiterate that my goal was to delete the directory and files. This solution is not about how to rename or move the file and directory names that are too long. The following will delete everything in a folder recursively!
Having said that, to delete the directories and files that are blocked from deletion because the file names are too long, use RoboCopy to mirror an empty directory over on top of the troubled directory. In my case, I did the following:
C:UsersWesleyDocuments>mkdir emptyfolder C:UsersWesleyDocuments>robocopy emptyfolder pathtobothersomefolder /MIR
I like to be thorough, so I use the following extra flags:
/V /LOG:C:mirrorlog.txt /TEE. The
/V stands for verbose,
/LOG sends the output to a log file and
/TEE makes sure to sent the output to the command prompt screen in addition to the log file so I can watch in real time.