This is common problem due to the inherited restriction of the Windows file system. The quickest way is to use robocopy that is now part of Windows Server 2012 and supports long file names. We are basically mirroring an empty directory to the directory we would like to delete and because the source is empty it will clear the destination directory. One done you can delete the empty_dir and the the_dir_to_delete.
mkdir empty_dir
robocopy empty_dir the_dir_to_delete /s /mir
rmdir empty_dir
rmdir the_dir_to_delete
oxishmit
2. November 2015 at 21:04Try Long Path Tool to solve your problem, it is amazing and free tool.
RZM
Author 2. November 2015 at 22:03Yes it does and it is a valuable tool. However, robocopy ships with Windows 2012R2 and if you only have on directory to clear up it is just as quick and no installation required, which might also be a problem in a corporate environment were more stringent security policies are applied.
Greg
18. October 2016 at 10:07Hi, This worked a treat for me in the circumstance you described, production environment under change control so native tool a big plus.
Peter Smith
22. November 2019 at 20:59Hii!
You can use LongPathTool. It will really help you.
It is make for this types of problems.