Filenames too long and Windows can't open the files

12

2

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?

FrustratedWithFormsDesigner

Posted 2012-01-10T20:46:14.897

Reputation: 1 298

@bZezzz: That looks like it would work on a file-by-file basis, but I'm looking for some what to make the whole bunch of them accessible all at once. Copying to local workstations would be OK but the long filenames must be preserved (they provide very specific context for the file contents). Also, many users here are not technical enough to start opening files from the command line. Your suggestion might work for me and one other person. – FrustratedWithFormsDesigner – 2012-01-10T21:52:57.410

Answers

7

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.

shufler

Posted 2012-01-10T20:46:14.897

Reputation: 1 716

2

I've recently faced this problem a lot & I've used the SUBST approach. For that purpose, I've found the Visual Subst tool available at http://www.ntwind.com/software/utilities/visual-subst.html to be invaluable.

– yosh m – 2012-01-11T00:02:27.040

6

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.

music2myear

Posted 2012-01-10T20:46:14.897

Reputation: 34 957

256 characters. – bZezzz – 2012-01-10T22:08:07.227

No, they need to use a program that is NOT Windows Explorer, because Windows Explorer is oblivious to the filesystem specs and lazily opts to stick to the least common denominator, making it impossible, for example, to simply copy the existing root of one drive to the root of another identical drive (in capacity, format, etc.) without running into PATH TOO LONG errors. – Triynko – 2012-09-14T05:19:37.700

1

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

kinokijuf

Posted 2012-01-10T20:46:14.897

Reputation: 7 734

0

EDIT: Originally I suggested using robocopy, but of course this is XP and that doesn't have it pre-installed.

There is no way you will be able to 'give everyone what they want' If the filepath is too long, you won't be able to do any file operations with it. The way I see it, you have a few options:

  1. Follow the steps of the other posts and rename the directories until they are short. The nice thing about computers is you can write a script to not only do this for you, but also keep track of what the original names were. Even with a script, this is bound to be somewhat time consuming.

  2. Get a Linux LiveCD. Put it into the computer and boot from that CD. Go see the Windows disk which will be automounted as a separate filesystem. Get all the files you want and put them into a new folder on your Desktop. Zip that folder and put it on an external hard drive or USB stick or if your network drive allows copying back to the filesystem, move it to a top-level directory.

aqua

Posted 2012-01-10T20:46:14.897

Reputation: 473

I don't have robocopy installed and I'm not sure I have access to install it (it's a work computer). Also, this sounds like a lot of work for each file. My example was simplified: there are actually several directories at several levels too-deep, each containing files that are now inaccessible due to path-too-long issues. I really don't have to time to do this for all the files that everyone wants. – FrustratedWithFormsDesigner – 2012-01-10T22:03:02.260