PDA

View Full Version : Dealing withLong file names in DOS


terryJones
23rd Nov 2006, 00:06
As a result of something occurring this week (See Burning DVD thread) I need to get into a file in Program Files whilst poking about in DOS.
The problem is, how do I do CD Program Files, as the break is not recognised by the cd command...
This goes of course for any double barrelled file name.
HELP.

terryJones
23rd Nov 2006, 00:39
Solved my own prob.
Seems that the old win 98 trick of c: \"program files will work ONLY if you get in via CMD and NOT COMMAND.....
We live and learn

robdesbois
23rd Nov 2006, 08:10
Older Windows and DOSs limited filenames to 8 characters, dot, 3 characters - which is known as 8.3 format for obvious reasons. Spaces are not allowed.

Since Windows 95/98 (can't remember which) Windows now uses long filenames (LFN) which can be up to 256 characters and any dots are your own decision.

To convert a LFN to 8.3 format, take the first 6 characters ignoring spaces
and add ~N onto it - where N is usually 1. If there are multiple files in a folder with the same 6 characters prefix, N increments for each of them in alphabetical order. If it is a file, not a folder, you can then append the .xxx extension.

So, "C:\Program Files" would become "C:\Progra~1"
If there was also "C:\Program Installers", this would become "C:\Progra~2".

Ok, enough geeking now...

Mac the Knife
23rd Nov 2006, 08:44
Careful out there. The 8.3 filename is synthesised from the LFN on the fly (it isn't static and isn't stored). The value of ~N depends on what other files there are in the directory/folder.

So mylongappname.exe might be MYLONG~1.EXE in one situation and MYLONG~2.EXE in another.

Old apps that don't understand LFNs can give you serious grief, particularly if they're doing any batch processing. Any files changed to 8.3 will have no idea what their previous LFN was.

LFNTOOLS - http://lfntools.sourceforge.net/ - might be useful to you and LFNDOS and DOSLFN (TSRs that handle long filenames under DOS) are of historical interest.

robdesbois
23rd Nov 2006, 09:17
Careful out there. The 8.3 filename is synthesised from the LFN on the fly (it isn't static and isn't stored). The value of ~N depends on what other files there are in the directory/folder.

Hence I said If there are multiple files in a folder with the same 6 characters prefix, N increments for each of them in alphabetical order.

:p

under_exposed
23rd Nov 2006, 11:28
Or just use dir /x