Delete really long paths and nested directories in windows using a Robocopy one line script
So, if you ever ran into a really long nested folder structure with really long names – cleaning up those files might be ugly since it gives you the “file too long to be deleted” error in Windows.
There are some workarounds with the SFN : short file names – installing 3rd party tools or creating a batch file to recursively rename/shorten/delete folders and files.
but another more simple alternative is the following:
- create an empty folder called “sourcefolder”
- in command line, browse to your directory, run the following command :
robocopy /purge sourcefolder really_shitty_folder_with_nested_long_files
What will happen is that robocopy will synchronize the 2 folders and deletes what doesn’t exist in source.
The source being an empty folder – robocopy will recursively delete everything.
Simple ;p


Hello. i was also having the same issue but Long Path Tool helped me in this situation. You can see here PathTooDeep.com. It might help you.
Thanks and Regards,
Attila
Thank you for the solution!
Worked wonderfully well, and I did not have to pay a dime!