Error deleting – File name is too long

I am almost positive you have run into this error before. Recently I have had 1000s of files like this.


Where did they come from? Both times it was a hidden cache folder for DropBox and AeroFS. I had been playing with both to see if I wanted to use them to sync my files.

Well, I found a simple way to blow these away in one shot, and you can use a tool within windows to do it.

It seems that robocopy can handle these long file names. What you do is you create an empty folder, and then use it to synchronize the copy while telling it to delete all the files that do not exist in the source (Your empty folder)

So if you are running into this, and just want the whole folder gone, get to a command line and create an empty folder.

I created one at c:empty

And lets say for our example here the offending folder is c:BadFolder

You would call robocopy like this:

robocopy c:empty c:badfolder /e /mir


The /e tells it to visit all sub folders even if they are empty, the /mir will tell it to delete any file or folder that does not exist in c:empty – which is everything.

So there it is. A simple trick to get around those pesky files that windows says are too long – no special tools needed.