java left logo
java middle logo
java right logo
 

Home arrow Other API Tips
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4093
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to use Move task E-mail
User Rating: / 8
PoorBest 

Move

Description

Moves a file to a new file or directory, or sets of files to a new directory. By default, the destination file is overwritten if it already exists. When overwrite is turned off, then files are only moved if the source file is newer than the destination file, or when the destination file does not exist.

FileSets are used to select sets of files to move to the todir directory.

Since Ant 1.6.3, the file attribute may be used to move (rename) an entire directory. If tofile denotes an existing file, or there is a directory by the same name in todir, the action will fail.

Parameters

Attribute Description Required
file the file or directory to move One of file or at least one nested fileset element
preservelastmodified Give the moved files the same last modified time as the original source files. (Note: Ignored on Java 1.1) No; defaults to false.
tofile the file to move to With the file attribute, either tofile or todir can be used. With nested filesets, if the fileset size is greater than 1 or if the only entry in the fileset is a directory or if the file attribute is already specified, only todir is allowed
todir the directory to move to
overwrite overwrite existing files even if the destination files are newer (default is "true") No
filtering indicates whether token filtering should take place during the move. See the filter task for a description of how filters work. No
flatten ignore directory structure of source directory, copy all files into a single directory, specified by the todir attribute (default is "false").Note that you can achieve the same effect by using a flatten mapper No
includeEmptyDirs Copy empty directories included with the nested FileSet(s). Defaults to "yes". No
failonerror If false, log a warning message, but do not stop the build, when the file to copy does not exist or one of the nested filesets points to a directory that doesn't exist or an error occurs while moving. No; defaults to true.
verbose Log the files that are being moved. No; defaults to false.
encoding The encoding to assume when filter-copying the files. since Ant 1.5. No - defaults to default JVM encoding
outputencoding The encoding to use when writing the files. since Ant 1.6. No - defaults to the value of the encoding attribute if given or the default JVM encoding otherwise.
enablemultiplemapping If true the task will process to all the mappings for a given source path. If false the task will only process the first file or directory. This attribute is only relevant if there is a mapper subelement. since Ant 1.6. No - defaults to false.
granularity The number of milliseconds leeway to give before deciding a file is out of date. This is needed because not every file system supports tracking the last modified time to the millisecond level. Default is 0 milliseconds, or 2 seconds on DOS systems. This can also be useful if source and target files live on separate machines with clocks being out of sync. since Ant 1.6.

Parameters specified as nested elements

mapper

You can define file name transformations by using a nested mapper element. The default mapper used by <copy> is the identity.

filterchain

The Move task supports nested FilterChains.

If <filterset> and <filterchain> elements are used inside the same <move> task, all <filterchain> elements are processed first followed by <filterset> elements.

Examples

Move a single file (rename a file)

  <move file="file.orig" tofile="file.moved"/>

Move a single file to a directory

  <move file="file.orig" todir="dir/to/move/to"/>

Move a directory to a new directory

  <move todir="new/dir/to/move/to">

    <fileset dir="src/dir"/>
  </move>
or, since Ant 1.6.3:
  <move file="src/dir" tofile="new/dir/to/move/to"/>

Move a set of files to a new directory

  <move todir="some/new/dir">
    <fileset dir="my/src/dir">
      <include name="**/*.jar"/>

      <exclude name="**/ant.jar"/>
    </fileset>
  </move>

Append ".bak" to the names of all files in a directory.

  <move todir="my/src/dir" includeemptydirs="false">
    <fileset dir="my/src/dir">
      <exclude name="**/*.bak"/>

    </fileset>
    <mapper type="glob" from="*" to="*.bak"/>
  </move>

Source: Apache Ant


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.