Task to determine the basename of a specified file, optionally minus a specified suffix.
When this task executes, it will set the specified property to the
value of the last path element of the specified file. If file
is a
directory, the basename will be the last directory element. If
file
is a full-path, relative-path, or simple filename,
the basename will be the simple file name, without any directory elements.
Attribute | Description | Required |
file | The path to take the basename of. | Yes |
property | The name of the property to set. | Yes |
suffix | The suffix to remove from the resulting basename
(specified either with or without the ". "). |
No |
will set<basename property="jar.filename" file="${lib.jarfile}"/>
jar.filename
to
myjar.jar
, if lib.jarfile
is defined as either a
full-path filename (eg., /usr/local/lib/myjar.jar
),
a relative-path filename (eg., lib/myjar.jar
),
or a simple filename (eg., myjar.jar
).
will set<basename property="cmdname" file="D:/usr/local/foo.exe" suffix=".exe"/>
cmdname
to foo
.
will set<property environment="env"/> <basename property="temp.dirname" file="${env.TEMP}"/>
temp.dirname
to the last directory element of
the path defined for the TEMP
environment variable.