When you want to completely delete a directory and it has file with long names inside it, robocopy does a VERY good job:
mkdir empty_dir
robocopy empty_dir the_dir_to_delete /s /mir
rmdir empty_dir
rmdir the_dir_to_delete
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.