devnumbertwo - $h!t for developers

View Original

cannot delete files – file name is too long

if you’re trying to delete files in Windows that are either too deep or whose names are too long you could get this error:

See this content in the original post

some articles will say to copy the contents to a shorter folder path OR rename the files (duh!) but in some cases this will not work. you end up getting the same error! i.e. copy the long-named file to somewhere else, it will say that the name is too long to perform that action. so I wouldn’t even bother trying that nonsense…

give this a shot, worked like a charm for me:

  1. drill down into the folders to the folder that contains the problem files or folders

  2. share the folder that contains the files/folders

  3. map a network drive to the folder with the problem files/folders

  4. open the mapped drive from another computer on the network, delete the files or folders in question

  5. disconnect the map drive and remove the share

how long can a file name be in windows? here’s what Microsoft says:

It depends on the length of the complete path to the file (such as C:\Program Files\filename.txt). Windows limits a single path to 260 characters. This is why you might occasionally get an error when copying a file with a very long file name to a location that has a longer path than the file’s original location.