Jump to content
Sign in to follow this  

[UDF] Return the short names of folders in MS-DOS

Recommended Posts


Howdy...i`ve created this UDF cuz I needed something that returns the short names of a given path in MS-DOS. I made a search on the forum and didn`t find anything related.

So here it is...maybe someone could make some use of it, besides me :).

Func _DOSShortNames($aPath)
    Local $sNameDOS, $cDrive, $strbtw, $fFolders
    $cDrive = StringLeft  ( $aPath, 2 )
    $strbtw = StringRight ( $aPath, StringLen ( $aPath ) - 3)
    $fFolders = StringSplit ( $strbtw, "\");[0]nr of folders [n] folders
    For $i = 1 To $fFolders[0]
        If StringLen ( $fFolders[$i] ) > 8 Then
            If Not StringInStr($fFolders[$i], " ", 0, 1) = 0 Then
                $fFolders[$i] = StringReplace ( $fFolders[$i], " " , "" , 0, 0)
                $fFolders[$i] = StringLeft ( $fFolders[$i], 6 ) & "~1"
                $fFolders[$i] = StringLeft ( $fFolders[$i], 6 ) & "~1"
        $sNameDOS =$sNameDOS &"\"&$fFolders[$i]
        Return $cDrive & $sNameDOS


_DOSShortNames("c:\this\is one of\my folders")

Returns: c:\this\isoneo~1\myfold~1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.