Delete files/directories Windows Server 2012 – Filename too long

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
  • Share:
  1. Try Long Path Tool to solve your problem, it is amazing and free tool.

  2. Yes 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.

  3. Hi, This worked a treat for me in the circumstance you described, production environment under change control so native tool a big plus.

  4. Hii!
    You can use LongPathTool. It will really help you.
    It is make for this types of problems.

Leave a Comment to Peter Smith Cancel Comment

Send a Message