PigRider Blogs

Sign In
HTML CSS Javascript Ruby on Rails C++ Java Python SQL Git Linux Others All

Delete a file in Windows with a too long filename

[Author: Dingyu]   [Mon, 2017-05-08, 20:44]   [261 views]


1. Open a "Windows Command Processor", or "cmd.exe"

2. Type below commands there to delete the folder:
mkdir empty_dir
robocopy empty_dir the_dir_to_delete /s /mir
rmdir empty_dir
rmdir the_dir_to_delete
Explanation: This works because robocopy internally uses the Unicode-aware versions of Win32 functions, with the \\?\ prefix for file paths; those functions have a limit of 2¹⁶-1 (32,767) characters instead of 259. You may need to go through this process more than once to get rid of all of the files. Found this solution from: https://superuser.com/questions/45697/how-to-delete-a-file-in-windows-with-a-too-long-filename