Handling Files/Directories With Very Large File Names

[]

Symptom
You cannot rename or delete a file or directory structure with the Windows Explorer or other tools, since its file name is too long (has more than 260 characters).
You get the error message: The file name or extension is too long.
Other terms
The filename or extension is too long
Reason and Prerequisites
On a Windows NTFS file system, the following file name schemes are possible:
Default Windows file name system
File names can be in non-Unicode or Unicode format. The file names are limited in total to 260 characters including the drive letter, the complete path to the directory, the file name and the file extension.Unicode file name system
The maximum file name length is about 32000 characters.
This naming system has a different syntax (\\?\c:\path\file.extension on local files or \\?\UNC\server\share\patch\file.extension on UNC paths).
File names must be Unicode only, and the application always has to use absolute paths. You cannot use relative paths (..\neighbour_directory\filename.extension).
Slashes (”/”) are not allowed as path separators.
All Windows programs (Windows Explorer, File-Open Dialogs, Dos-Box, Powershell, and all command line tools that are delivered with the operating system) cannot handle the Unicode file name system.
Some Java-based applications only use the Unicode file name system and create file names longer than 260 characters, which common Windows tools cannot handle.
Solution
To access these large directories with common Windows tools, you have to create symbolic links (junctions) using shorter names for the upper directories.
To create links, you require one of the following executables:
linkd.exe (included in the Windows Server 2003 Resource Kit, and (available as free download from Microsoft)junction.exe (available as free download from www.sysinternals.com)
Example:
There is the following directory available:
C:\1234567890123456789012345678901234567890123456789012345678901234567890132456789012345678901234567890123456789012345678901234567980 (133 characters)
This directory has an additional subdirectory:
dir
23.04.2009 11:30 <DIR> 1234567890123456789012345678901234567890123456789012345678901234567980132456789012345678901234567890123456789012345678901234567980 (additional 130 characters)
Already changing to this directory is not possible:
cd 1234567890123456789012345678901234567890123456789012345678901234567980132456789012345678901234567890123456789012345678901234567980
The specified path cannot be found and the directory cannot be removed either.
Solution:
1. Create a short link to the first directory:
linkd.exe c:\short C:\12345678901234567890123456789012345678901234567890123456789012345678901324567890123456789012345678901234567890123456789012345679802. Access the directory structure with the short link:
cd c:\short\12345678901234567890123456789012345678901234567890123456789012345679801324567890123456789012345678901234567890123456789012345679803. Now you can access the files in this directory:
dir
07.05.2009 21:47 1.138 a_normalFile.txt4. Depending on the length of the file name, you have to repeat this procedure until you can access the file or directory with the longest name.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Leave a Comment