8.3 paths with ~

General development discussion.

Moderators: Susan Smith, admin, Gabriel

Post Reply
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

8.3 paths with ~

Post by John »

what's the best way to convert a long path with things like "Documents and Settings" in it to a 8.3 path with things like "Docum~1" in it?

-John
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

no ideas?
Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

Post by Gabriel »

It doesn't seem like it would be to hard to write a function that does it.
PJKLUG
Posts: 31
Joined: Tue Jun 09, 2009 9:29 am

8.3 paths with ~

Post by PJKLUG »

Back in the days when Windows gave us long file names and DOS didn't know what to do with them the "Docum~1" came to pass. I assumed Windows kept a cross reference table of both names. I don't know if it was dynamic or stayed assigned for the life of the path. "Docum~1" would be "Docum~2" and "Docum~3" based on the number of "Documents and Settings" that existed or anything longer that 8 characters that started with "Docum". I wonder if when the "Docum~2" path was removed if "Docum~3" would revert to "Docum~2"? That could create user maintained table issues. I suppose if you controlled the path parts that you were abbreviating you could use the "config substitute" command to re-expand when needed. I am not sure this is what you were trying to accomplish or not. When BR gave us the "full" path along with the DOS path in the BR DIR command it solved my issues.
Susan Smith
Posts: 717
Joined: Sun Aug 10, 2008 4:24 am
Location: Southern California

Post by Susan Smith »

John,

Since you know some VB, you could write a little wrapper around the Windows API function:

GetShortPathName

-- Susan
GomezL
Posts: 258
Joined: Wed Apr 29, 2009 5:51 am
Contact:

Post by GomezL »

dir @::C:\windows

Directory of @::C:\windows\*.*
. <DIR> 09/29/11 7:20a .
.. <DIR> 09/29/11 7:20a ..
addins <DIR> 07/14/09 1:32a addins
APPCOM~1 <DIR> 07/13/09 11:20p AppCompat
AppPatch <DIR> 08/10/11 3:23a AppPatch
assembly <DIR> 09/23/11 10:30a assembly
atiogl xml 19017 12/08/09 10:41p atiogl.xml
ativpsrm bin 0 03/01/11 3:20a ativpsrm.bin
bfsvc exe 71168 11/20/10 9:24a bfsvc.exe
BITLOC~1 <DIR> 09/23/11 7:30a BitLockerDiscoveryVolumeContents

in BR, the 8.3 name is displayed in the 1st 13 characters.
If it's not, then there is no 8.3 name.
Susan Smith
Posts: 717
Joined: Sun Aug 10, 2008 4:24 am
Location: Southern California

Post by Susan Smith »

I think I may have misunderstood when I suggested the Windows API call GetShortPathName. I thought that John was looking for the short PATH name rather than the file names. For short FILE names, I do the same as Luis, and parse the results of DIR.

-- Susan
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

Okay - thanks for everyone's input. For me this is a one time process during startup - And I don't want to do any guessing - I want it to always be correct... also I didn't want to take a long time to write a solution - SO - I've developed a little dos batch file to call. It looks something like this:

echo off
if '%1'=='' goto HELP
if '%2'=='' goto HELP
set homepath="%~1"
set homedir=%~d1
for %%A in (%HOMEPATH%) do set HOMEPATH=%%~spnxA
echo %homedir%%homepath%
echo %homedir%%homepath% >%2
goto XIT
:HELP
echo Proper Usage is:
echo %0 [path_input] [outputfile]
echo [path_input] - a long path to parse. quote encapsulation is required
echo i.e. "C:\Long Path To Parse\etc"
echo [outputfile] - file to output resulting short path to.
:XIT

Thank you all!
Post Reply