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

4 comments

  1. 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.

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

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *