Saturday, 26 December 2015

Resolving long path errors deleting files in Windows

One of the most detested situations in just about any version of Windows is to receive the message that the path to a file or folder is too long. There are a number of variations of this message but one that is commonly seen when trying to delete files is "The source filenames are larger than is supported by the filesystem" which is an absolute load of BS and a total pack of lies. This is because the filesystem allowed these files to be created in the first place.

What is happening is that the filesystem since the advent of the Win32 API on Windows NT (the predecessor of Windows 10 going back to the very first version ever produced, NT 3.1 of 1993) has, in fact, supported paths up to 32768 characters in length, but because Windows Explorer was designed for a previous version of Windows (16-bit i.e. Windows 95 and its predecessors) that only supported 259 character paths (drive letter, colon and backslash plus 256 characters), it still enforces that limit. This creates a huge problem when trying to delete old files or paths (for example cleaning up the contents of a backup disk and removing old backups to make way for new ones).

The fact MS has never bothered to fix Explorer which means a huge inconvenience for many users means everyone has to find a way of bypassing Explorer to fix these problems. There are a number of different solutions which I have seen at different times.
  • A special script calling Robocopy to reach the bottom of a directory path and move each directory up one level at a time until it can be deleted. I used this one but can't recall where I got it from.
  • A useful looking program called Long Path Fixer appears to be able to address this problem. I have not tried testing this software.
  • The simplest option which I am now using is the file manager from 7-Zip. Since this excellent piece of software is already on all my computers, this has been the easiest to test and implement and has proved to do exactly what is needed provided it is used in the right way.
Specifically you start up the 7-Zip File Manager, then use that to browse to the folder you want to delete, select the folder and then using the keyboard press the Del key to recycle, or Shift+Del to delete outright. Note that pressing the Delete button or right clicking and choosing Delete actually work differently and are not as reliable as they will still produce the detestable error message. You have to use the keyboard commands to guarantee hassle-free results.

So after all of the huge hassles and inconvenience that MS has inflicted over the years due to a huge amount of uselessness from its programmers then being able to solve this problem is a great step forward.