Filenames too long and Windows can't open the files

There's a bunch of files on a network drive, on a fairly deep path and the directories on most of of have long names. I think that these were originally created when someone copied & pasted the root directory for this group of files from their local workstation to the shared network drive. I imagine that on the local workstation, there was no problem opening the file, but now that they are on a longer path on the network, Windows can't open them when I double-click. I've also tried copying the files, and renaming them to somethign shorter, but Windows is unable to do that as well.

TL;DR

files from someone's workstation on a (hypothetical) path like this:

C:\Documents and Settings\SomeUser\Files\RootOfLongFileNames\LongSubdirectoryName1\...\VeryLongAndDescriptiveAndSpecificFilename.xls
-----------------------------------------^

have now been copied and pasted on to the network like this:

Q:\Dir1\Dir2\ProjectA\FilesForSomething\SomeotherDirectory\Blahblah\RootOfLongFileNames\LongSubdirectoryName1\...\VeryLongAndDescriptiveAndSpecificFilename.xls
---------------------------------------------------------------------^

And the path is now too long for Windows XP to handle.

Any tips as to how I can read these files?


Solution 1:

Try substituting the path with SUBST.EXE. It comes with Windows:

C:\Users\shufler>subst /?
Associates a path with a drive letter.

SUBST [drive1: [drive2:]path]
SUBST drive1: /D

  drive1:        Specifies a virtual drive to which you want to assign a path.
  [drive2:]path  Specifies a physical drive and path you want to assign to
                 a virtual drive.
  /D             Deletes a substituted (virtual) drive.

Type SUBST with no parameters to display a list of current virtual drives.

What you want to do is substitute one of the folders down the chain for a drive letter:

 C:\>subst X: Q:\Dir1\Dir2\ProjectA\FilesForSomething\SomeotherDirectory\Blahblah\RootOfLongFileNames\LongSubdirectoryName1

Now the LongSubdirectoryName1 folder is accessed on the X: drive. When you're done with it you can delete your substitution with subst X: /D

If you need this all the time, then add it to your login script.

Another approach would be to map a drive further down the chain from wherever Q: is mapped.

Solution 2:

You'll need to rename directory names in the path until the name is short enough for the OS to access.

I'd navigate to the first folder whose name you can modify and rename it to a single letter and then do the same for each subsequent folder until you get to the necessary file.

Regarding the necessity of keeping the structure: There are limitations which we have to work within on Operating Systems, and it is not good to routinely operate outside those parameters. Any quick solution now will only ever be a patch that will need to be re-run again in the future. A true solution will involve reorganizing the directory structure such that this extremely long folder path/file name issue is no longer necessary.

Solution 3:

Prefix the path with \\?\. Note that this doesn’t work with all apps.