If you are using a command prompt you could do something like:
Code: Select all
::
:: TC_QueryINIPath.cmd
::
@ECHO OFF
FOR /F "delims=" %%F IN ("%COMMANDER_INI%") DO SET TCINI_PATH=%%~pF
Dunno if that's WINE friendly or not. But this would (should?) work WINE/Linux,
Code: Select all
basename "%COMMANDER_INI%" wincmd.ini
May need to change how the variable is referenced, maybe: $COMMANDER_INI ... ?
And this would work, with AutoHotkey,
Code: Select all
EnvGet, TCINI, COMMANDER_INI
SplitPath, TCINI,, path
path.="\"
MsgBox, path: %path%
EDIT:
And for completeness, here's a few path related functions I wrote for AHK:
Code: Select all
SplitPathCMD(fullPath, byref str1, byRef str2="", byref str3="", byRef str4="")
{
Loop, %fullPath%, 1
fullPath:=A_LoopFileLongPath
if( inStr(FileExist(fullPath), "D") )
slash:=(SubStr(fullPath, 0) <> "\" ? "\" : "")
else
fullPath:=(SubStr(fullPath, 0) == "\" ? SubStr(fullPath, 1,-1) : fullPath)
Loop, 4
{
out:=""
if(!sTmp:=str%A_Index%)
break
if(inStr(sTmp, "s") || ((full:=fullPath) && FALSE))
Loop, %fullPath%, 1
full:=A_LoopFileShortPath
if((inStr(sTmp, "f") && str%A_Index%:=full) || ((full.=slash) && FALSE))
continue
SplitPath, full, aFile, aDir, aExt, aNameOnly, aDrive
out:=(inStr(sTmp, "dp") ? aDir : inStr(sTmp, "d") ? aDrive : inStr(sTmp, "p")
? (RegExReplace(aDir, "^.:", aDir==aDrive ? "\" : "")(aFile ? "\" : "")) : "")
out.=(inStr(sTmp, "nx") ? aFile : inStr(sTmp, "n") ? aNameOnly : (inStr(sTmp, "x") && aExt) ? "." aExt : "" )
str%A_Index%:=out
}
}
SplitPath( fullPath, byRef aFile="", byRef aDir="", byRef aExt="", byRef aDrive="", byRef aNameOnly="" )
{
fullPath.=((inStr(FileExist(fullPath), "D") && SubStr(fullPath, 0) <> "\") ? "\" : "")
SplitPath, fullPath, aFile, aDir, aExt, aNameOnly, aDrive
aDir.=(aDir && (aDir==aDrive)) ? "\" : ""
return
}
Example usage of SplitPathCMD() ... uses the same/similiar syntax as CMD.exe variable referencing:
Code: Select all
EnvGet, TCINI, COMMANDER_INI
SplitPathCMD(TCINI, path:="dp")
MsgBox, path: %path%
Will handle the CMD.exe letters, f d p s n x --- although f will exclude/trump the others.
E.G.
SplitPathCMD(TCINI, fullPath:="f", drive:="d", ext:="x", shortname:="snx")
MsgBox, fullpath: %fullpath%`ndrive: %drive%`next: %ext%`nshortname: %shortname%