Special syntax for CMD.EXE compatibility

Print Topic  Return to Overview  Previous Topic  Next Topic 

For compatibility with CMD.EXE, TCC supports additional syntax to qualify references to parameters of batch files and the control variable of the FOR command when referenced by the command it executes. However, this syntax can usually be replaced by the more flexible Variable Functions.

 

CMD.EXE syntax

Expands to

Suggested replacement

%*

All parameters

%$

%~n

unquoted (")

%@replace[^",,%n]

%~fn

Fully qualified name of %n

%@full[%n]

%~dn

Drive letter portion of %n

%@left[2,%@full[%n]]

%~pn

Full path (no drive letter) of %n

%@right[-2,%@path[%@full[%n]]]

%~nn

Root name (no extension) of %n

%@name[%n]

%~xn

File extension of %n

.%@ext[%n]

%~sn

Fully qualified short name of %n

%@sfn[%n]

%~an

File attributes of %n

%@attrib[%n]

%~tn

File date and time of %n

%@filedate[%n] %@filetime[%n]

%~zn

File size of %n, bytes

%@filesize[%n]

%~$PATH:n

Full name of the first match for %n in %PATH

%@search[%n]

 

Notes

 

In the special case where the parameter to a %~ variable is 0, e.g., %~f0, the returned file name will always include the extension, as it does under CMD.EXE.

 

%~$PATH:n returns an empty string if the file %n is not found in the path.

 

References qualified by the tilde ~ trigger an error message when used improperly, e.g. if attempting to display the size of a string parameter which is not the name of a file.

 

Topic "cmdsyntax.htm" last edited 5/13/2008. ©2008  JP Software, Inc.
Keywords: CMD.EXE