Convert UNC to 8.3 - Is there such a thing?

Started by jtrask, July 27, 2016, 07:20:51 AM

Previous topic - Next topic

jtrask

Can a UNC path be converted to 8.3 format?  I found a vbscript that was rumored to do it, but I'm not find that to be the case.

td

Can't tell you about VBS but check out the 'FileNameShort' function in the Consolidated WIL Help file.  The function will not convert a server name or share name but the other segments of the path, include any file name,  should convert.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

jtrask

That wasn't working for me.  I've used FileNameShort in the past, but when I looked at my previous scripts, they had all been local paths. That's why I detoured to vbscript.   Here's how it was behaving for me.

sFile = "C:\Data\Winbatch\Test\Folder name with spaces\test.txt
message("Short",FileNameShort(sFile))

Responds with "C:\Data\Winbatch\Test\FOLDER~1\test.txt"

sFile = "C:\Data\Winbatch\Test\Folder name with spaces\test file with spaces.txt
Message("Short",FileNameShort(sFile))

Responds with "C:\Data\Winbatch\Test\FOLDER~1\TESTFI~1.TXT"

sFile = "\\CORDALSV01\AppSource$\Oracle Corporation\Java 8 Update 101\Java 8 Update 101 8.0.1010.13\java.settings.cfg"
Message("Short",FileNameShort(sFile)

Responds with "\\CORDALSV01\AppSource$\Oracle Corporation\Java 8 Update 101\Java 8 Update 101 8.0.1010.13\java.settings.cfg"

td

FileNameShort can definitely produce short names for shares.  I have used it on shares many times to workaround extended path length limitations.  However, the operation system involved needs to support 8.3 names and have it enabled.  For example, the most common Windows file system, NTFS, supports 8.3 names but it is not necessarily enabled. 

I am not sure if both the machine hosting the share and the machine accessing the share need to have 8.3 support or if only the machine accessing the share needs to support path 8.3 segment names. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Also, 8.3 file names can be disabled on a per volume basis on Windows 7/2008 R2 and newer systems.  On newer system short name support can also be configured to only create 8.3 names on the system volume, 'C:' for example.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

snowsnowsnow

Quote from: td on July 27, 2016, 01:05:27 PM
FileNameShort can definitely produce short names for shares.  I have used it on shares many times to workaround extended path length limitations.  However, the operation system involved needs to support 8.1 names and have it enabled.  For example, the most common Windows file system, NTFS, supports 8.1 names but it is not necessarily enabled. 

I am not sure if both the machine hosting the share and the machine accessing the share need to have 8.1 support or if only the machine accessing the share needs to support path 8.1 segment names.

I assume you mean 8.3 not 8.1 (I kept thinking you were talking about an old version of Windows there...)

Second, yes, I can confirm.  It does work.  You can use FileNameShort() on a UNC and it does the expected thing.

td

Welcome back and yes, I meant 8.3.  Thanks.  I will change it so as not to confuse anyone else.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Should add that since NTFS stores 8.3 names on the physical media, it would seem logical that the computer hosting the share would need to have MS DOS 8.3 names enabled if 8.3 are to be obtained for a UNC path. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade