<basename>

The <basename> task can be used to determine the last element in a given path, be it relative, absolute, or just a simple filename. The specified property will be given this value. It is a simple task with only three attributes, as listed in Table 4.8.

Table 4.8. Table of <basename> Attributes
Attributes Description
Required
file The full or relative path of the file from which the <basename> will be taken. Note that the file does not have to exist.
property The property to set the value of.
Optional
suffix If the specified file ends with the specified suffix (with or without the “.”), it will be removed.

Examples

The following example results in the property filename being set to chapter4.doc:

 <basename property="filename" file="C:\Documents\Sams\AntHandbook\chapter4.doc" ...

Get Ant Developer’s Handbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.