$fname (parse-spec) function
The file name portion of the path name given by parse-spec is returned. The parse-spec returns a standard path name with either a slash or backslash. This can be used to strip the path name, or ignore the path name component of a full path name to a file.
The following examples show target strings, parse expressions, and return values:
Target string | Parse expression | Return value |
|---|---|---|
File installationDirectory\X.txt | $fname (file *) | X.txt |
F1: /susr/pass.x | $fname (f1: *) | pass.x |
Test - P: /x y z/aaa.exe - EOM | $fname ($delim(spdash, p: *)) | aaa.exe Explanation: The path name contains a space, so you must specify the spdash delimiter. For other delimiters, see Parse-delimiters. |
C:\x\y\zzz.xls | $suffix ($fname($1)) | xls Explanation: The value is the suffix from the file at the specified path name. |
C:\x\y\zzz.xls
| $basename ($fname($1)) | zzz Explanation: The value is the file name (without the suffix) from the file at the specified path name. |
Related topic