Apache Ant Move Task

This task is used to move a file to new file or directory. It can also be used to move set of files to a new directory. By default destination files are overwritten if the files are already exists.

The file attribute is used to move a file or entire directory to a new destination directory.

AttributeDescriptionRequired
fileThe file or directory to be moved.Yes
preservelastmodifiedPreserve the last moved file nameNo
tofileThe destination file.Yes
todirThe destination directory.Yes
overwriteIt overwrites existing files even if the destination files are newer.No
forceIt overwrites read-only destination files.No
filteringIt indicates whether token filtering should take place during the move.No
flattenIt ignores directory structure of source directory.No
includeEmptyDirsIt copies empty directories.No
failonerrorIf false, log a warning message.No
quietIt does not log a warning message when the file to copy does not exist.No
verboseLog the files that are being moved.No
encodingIt is used to specify encoding format.No
outputencodingThe encoding to use when writing the files.No

Apache Ant Move Task Example

Moving file to new file.

Moving a file to a directory.

Moving a directory to new directory.





Latest Courses