Basename
Description
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. Iffile
is a full-path, relative-path, or simple filename, the basename will be the simple file name, without any directory elements.
Parameters
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 Examples
will set<basename property="jar.filename" file="${lib.jarfile}"/>jar.filename
tomyjar.jar
, iflib.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
tofoo
.will set<property environment="env"/> <basename property="temp.dirname" file="${env.TEMP}"/>temp.dirname
to the last directory element of the path defined for theTEMP
environment variable.