Sunday, April 16, 2017

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?


Answer



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.


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...