Page 1 of 1 1
Topic Options
#157709 - 2006-02-23 09:22 AM Shortfn() - A Function to return the short filename of a path
Arend_ Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Like the topic says, for instance Shortfn("C:\Documents and Settings") would return "C:\Docume~1"

In light of that Longfn() would be a nice addition as well.
Since this could be scripted, the reason I ask for it to be implemented as a kix function is that one can never shorten to short filenames and be accurate.

Top
#157710 - 2006-02-23 10:53 AM Re: Shortfn() - A Function to return the short filename of a path
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

Since this could be scripted, the reason I ask for it to be implemented as a kix function is that one can never shorten to short filenames and be accurate.




What do you mean that you cannot be accurate?

This works for me:
Code:
$=SetOption("WrapAtEOL","ON")

$sPath="C:\Documents and Settings"
"Short path for '"+$sPath+"' is '"+funShortFN($sPath)+"'"+@CRLF

Function funShortFN($s)
Dim $oFSO,$oFile
$oFSO=CreateObject("Scripting.FileSystemObject")
If 16 & GetFileAttr($s)
$funShortFN=$oFSO.GetFolder($s).ShortPath
Else
$funShortFN=$oFSO.GetFile($s).ShortPath
EndIf
EndFunction


Top
#157711 - 2006-02-23 11:06 AM Re: Shortfn() - A Function to return the short filename of a path
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Here is some further information on the subject.

8.3
From Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/8.3

File Allocation Table
http://en.wikipedia.org/wiki/File_Allocation_Table
 
Not directly related to your request but further information on file systems
 

NTFS
http://en.wikipedia.org/wiki/NTFS
 
How NTFS Reserves Space for its Master File Table (MFT)
http://support.microsoft.com/kb/174619
 
Master File Table
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/master_file_table.asp

Files Excluded by the Disk Defragmenter Tool
http://support.microsoft.com/kb/227350
 
How to create and manipulate NTFS junction points
http://support.microsoft.com/kb/205524
 

Top
#157712 - 2006-02-23 11:33 AM Re: Shortfn() - A Function to return the short filename of a path
Arend_ Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Oh man, I never thought about oFSO.GetFolder....
Please forgive my ignorance on this subject..

Top
#157713 - 2006-02-23 11:45 AM Re: Shortfn() - A Function to return the short filename of a path
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
No sweat, it's useful to have the question raised in case anyone else is searching for the info.
Top
#157714 - 2006-02-23 11:49 AM Re: Shortfn() - A Function to return the short filename of a path
Arend_ Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Thanks
Top
#157715 - 2006-02-23 06:15 PM Re: Shortfn() - A Function to return the short filename of a path
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
fnGetFileProp() and fnGetFolderProp() will return the shortpath (and other attributes).

Edited by Chris S. (2006-02-23 06:19 PM)

Top
#157716 - 2006-02-24 11:13 AM Re: Shortfn() - A Function to return the short filename of a path
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Bingo - I was looking for this =)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#157717 - 2006-02-24 06:10 PM Re: Shortfn() - A Function to return the short filename of a path
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Some people don't like the FSO dependency.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#157718 - 2006-02-24 07:34 PM Re: Shortfn() - A Function to return the short filename of a path
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I'm not sure why. Its been a part of the OS since Windows 95.
Top
#157719 - 2006-02-24 08:12 PM Re: Shortfn() - A Function to return the short filename of a path
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
I'm not so sure it was native in Windows 95, you could add it with VB or WSH but don't think it was native till Windows 98
Top
Page 1 of 1 1


Moderator:  Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 707 anonymous users online.
Newest Members
min_seow, Audio, Hoschi, Comet, rrosell
17881 Registered Users

Generated in 0.059 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org