This is more of a trick. Back in the day we had to use subst on the path to make it shorter to delete it.
So what this does is use robocopy, which does not have a problem with long name, and tell it to mirror a blank folder on top of the problematic folder. Since the source folder is empty it removes all files and folders.
robocopy C:\temp\empy_dir E:\dir_with_long_names /MIR