(view source code of truename.rex as plain text)
/* TRUENAME.CMD *//* Equivalent for MS-DOS' TRUENAME command (at least for *//* NET USEd drives) *//* Written by Rob van der Woude *//* http://www.robvanderwoude.com *//* *//* Written for both OS/2 2.1+ and Windows 95/NT with Regina *//* Rexx (Resource Kit) and Patrick TJ McPhee's RegUtil *//* (http://www.interlog.com/~ptjm/) *//* Initialize RexxUtil if necessary */if RxFuncQuery( "SysDriveMap" ) <> 0 then do
call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
call SysLoadFuncsendparse upper arg parameters
if parameters = "" then call Syntax
if pos( "?", parameters ) > 0 then call Syntax
if pos( "/", parameters ) > 0 then call Syntax
if pos( ",", parameters ) > 0 then call Syntax
if pos( ";", parameters ) > 0 then call Syntax
selectwhen left( parameters, 2 ) = "\\" then call Syntax
when left( parameters, 1 ) = "\" then do
drive = left( directory( ), 2 )
path = parameters endwhen length( parameters ) < 2 then do
drive = left( directory( ), 2 )
path = substr( directory( )||parameters, 3 )
endwhen substr( parameters, 2, 1 ) = ":",
& datatype( left( parameters, 1 ), "U" ) = 1 then do
drive = left( parameters, 2 )
path = substr( parameters, 3 )
endotherwise do
drive = left( directory( ), 2 )
path = substr( directory( )||parameters, 3 )
endendparse upper source os .
localdrives = SysDriveMap( "A", "LOCAL" )
if pos( drive, localdrives ) > 0 then do
truename = drive||path
say truenameEXIT 0
endstart = "A"
do i = 65 to 90
char = D2C( i )
if pos( char||":", localdrives ) = 0 then leave
start = D2C( i + 1 )
end/*do i = 1 by 1 until localdrives = "" parse value localdrives with local.i localdrives local.0 = iend*/remotedrives = SysDriveMap( start, "REMOTE" )
if pos( drive, remotedrives ) > 0 then do
tempfile = SysTempFileName( "TRUE????" )
'@NET USE '||drive||' | find "\\" > '||tempfile
line = linein( tempfile )
call lineout tempfile
parse value line with ."\\"strunc
unc = "\\"||strunc
if left( path, 1 ) <> "\" then do
"@CD "||drive||" > "||tempfile
line = linein( tempfile )
call lineout tempfile
path = substr( line, 3 )
end call SysFileDelete tempfiletruename = unc||path
say truenameEXIT 0
endsay "UNKNOWN"
EXIT 1
Syntax: procedure
call SysCls saysay "TrueName, Version 1.01"
say "Partial port of MS-DOS' TRUENAME command"
say "Written by Rob van der Woude"
say "http://www.robvanderwoude.com"
saysay "Usage: TRUENAME { drive | path | filename }"
saysay "Returns: the local name or UNC of the specified drive/path/filename"
EXIT 1
returnpage last modified: 2025-10-11; loaded in 0.0085 seconds