You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

move.html 7.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Move Task</title>
  5. </head>
  6. <body>
  7. <h2><a name="move">Move</a></h2>
  8. <h3>Description</h3>
  9. <p>Moves a file to a new file or directory, or sets of files to
  10. a new directory. By default, the
  11. destination file is overwritten if it already exists. When <var>overwrite</var> is
  12. turned off, then files are only moved if the source file is newer than
  13. the destination file, or when the destination file does not exist.</p>
  14. <p><a href="../CoreTypes/fileset.html">FileSet</a>s are used to select sets of files
  15. to move to the <var>todir</var> directory.</p>
  16. <p><b>Since Ant 1.6.3</b>, the <i>file</i> attribute may be used to move
  17. (rename) an entire directory. If <i>tofile</i> denotes an existing file, or
  18. there is a directory by the same name in <i>todir</i>, the action will fail.
  19. </p>
  20. <h3>Parameters</h3>
  21. <table border="1" cellpadding="2" cellspacing="0">
  22. <tr>
  23. <td valign="top"><b>Attribute</b></td>
  24. <td valign="top"><b>Description</b></td>
  25. <td align="center" valign="top"><b>Required</b></td>
  26. </tr>
  27. <tr>
  28. <td valign="top">file</td>
  29. <td valign="top">the file or directory to move</td>
  30. <td valign="top" align="center">One of <var>file</var> or
  31. at least one nested fileset element</td>
  32. </tr>
  33. <tr>
  34. <td valign="top">preservelastmodified</td>
  35. <td valign="top">Give the moved files the same last modified
  36. time as the original source files.
  37. (<em>Note</em>: Ignored on Java 1.1)</td>
  38. <td valign="top" align="center">No; defaults to false.</td>
  39. </tr>
  40. <tr>
  41. <td valign="top">tofile</td>
  42. <td valign="top">the file to move to</td>
  43. <td valign="top" align="center" rowspan="2">With the <var>file</var> attribute,
  44. either <var>tofile</var> or <var>todir</var> can be used. With nested filesets,
  45. if the fileset size is greater than 1 or if the only entry in the fileset is a
  46. directory or if the <var>file</var> attribute is already specified, only
  47. <var>todir</var> is allowed</td>
  48. </tr>
  49. <tr>
  50. <td valign="top">todir</td>
  51. <td valign="top">the directory to move to</td>
  52. </tr>
  53. <tr>
  54. <td valign="top">overwrite</td>
  55. <td valign="top">overwrite existing files even if the destination
  56. files are newer (default is &quot;true&quot;)</td>
  57. <td valign="top" align="center">No</td>
  58. </tr>
  59. <tr>
  60. <td valign="top">filtering</td>
  61. <td valign="top">indicates whether token filtering should take place during
  62. the move. See the <a href="filter.html">filter</a> task for a description of
  63. how filters work.</td>
  64. <td valign="top" align="center">No</td>
  65. </tr>
  66. <tr>
  67. <td valign="top">flatten</td>
  68. <td valign="top">ignore directory structure of source directory,
  69. copy all files into a single directory, specified by the <var>todir</var>
  70. attribute (default is &quot;false&quot;).Note that you can achieve the
  71. same effect by using a <a href="../CoreTypes/mapper.html#flatten-mapper">flatten mapper</a></td>
  72. <td valign="top" align="center">No</td>
  73. </tr>
  74. <tr>
  75. <td valign="top">includeEmptyDirs</td>
  76. <td valign="top">Copy empty directories included with the nested FileSet(s).
  77. Defaults to &quot;yes&quot;.</td>
  78. <td valign="top" align="center">No</td>
  79. </tr>
  80. <tr>
  81. <td valign="top">failonerror</td>
  82. <td valign="top">If false, log a warning message, but do not stop the
  83. build, when the file to copy does not exist or one of the nested
  84. filesets points to a directory that doesn't exist or an error occurs
  85. while moving.
  86. </td>
  87. <td valign="top" align="center">No; defaults to true.</td>
  88. </tr>
  89. <tr>
  90. <td valign="top">verbose</td>
  91. <td valign="top">Log the files that are being moved.</td>
  92. <td valign="top" align="center">No; defaults to false.</td>
  93. </tr>
  94. <tr>
  95. <td valign="top">encoding</td>
  96. <td valign="top">The encoding to assume when filter-copying the
  97. files. <em>since Ant 1.5</em>.</td>
  98. <td align="center">No - defaults to default JVM encoding</td>
  99. </tr>
  100. <tr>
  101. <td valign="top">outputencoding</td>
  102. <td valign="top">The encoding to use when writing the files.
  103. <em>since Ant 1.6</em>.</td>
  104. <td align="center">No - defaults to the value of the encoding
  105. attribute if given or the default JVM encoding otherwise.</td>
  106. </tr>
  107. <tr>
  108. <td valign="top">enablemultiplemapping</td>
  109. <td valign="top">
  110. If true the task will process to all the mappings for a
  111. given source path. If false the task will only process
  112. the first file or directory. This attribute is only relevant
  113. if there is a mapper subelement.
  114. <em>since Ant 1.6</em>.</td>
  115. <td align="center">No - defaults to false.</td>
  116. </tr>
  117. <tr>
  118. <td valign="top">granularity</td>
  119. <td valign="top">The number of milliseconds leeway to give before
  120. deciding a file is out of date. This is needed because not every
  121. file system supports tracking the last modified time to the
  122. millisecond level. Default is 0 milliseconds, or 2 seconds on DOS
  123. systems. This can also be useful if source and target files live
  124. on separate machines with clocks being out of sync. <em>since Ant
  125. 1.6</em>.</td>
  126. </tr>
  127. </table>
  128. <h3>Parameters specified as nested elements</h3>
  129. <h4>mapper</h4>
  130. <p>You can define file name transformations by using a nested <a
  131. href="../CoreTypes/mapper.html">mapper</a> element. The default mapper used by
  132. <code>&lt;copy&gt;</code> is the <a
  133. href="../CoreTypes/mapper.html#identity-mapper">identity</a>.</p>
  134. <h4>filterchain</h4>
  135. <p>The Move task supports nested <a href="../CoreTypes/filterchain.html">
  136. FilterChain</a>s.</p>
  137. <p>
  138. If <code>&lt;filterset&gt;</code> and <code>&lt;filterchain&gt;</code> elements are used inside the
  139. same <code>&lt;move&gt;</code> task, all <code>&lt;filterchain&gt;</code> elements are processed first
  140. followed by <code>&lt;filterset&gt;</code> elements.
  141. </p>
  142. <h3>Examples</h3>
  143. <p><b>Move a single file (rename a file)</b></p>
  144. <pre>
  145. &lt;move file=&quot;file.orig&quot; tofile=&quot;file.moved&quot;/&gt;
  146. </pre>
  147. <p><b>Move a single file to a directory</b></p>
  148. <pre>
  149. &lt;move file=&quot;file.orig&quot; todir=&quot;dir/to/move/to&quot;/&gt;
  150. </pre>
  151. <p><b>Move a directory to a new directory</b></p>
  152. <pre>
  153. &lt;move todir=&quot;new/dir/to/move/to&quot;&gt;
  154. &lt;fileset dir=&quot;src/dir&quot;/&gt;
  155. &lt;/move&gt;
  156. </pre>
  157. <i>or, since Ant 1.6.3:</i>
  158. <pre>
  159. &lt;move file=&quot;src/dir&quot; tofile=&quot;new/dir/to/move/to&quot;/&gt;
  160. </pre>
  161. <p><b>Move a set of files to a new directory</b></p>
  162. <pre>
  163. &lt;move todir=&quot;some/new/dir&quot;&gt;
  164. &lt;fileset dir=&quot;my/src/dir&quot;&gt;
  165. &lt;include name=&quot;**/*.jar&quot;/&gt;
  166. &lt;exclude name=&quot;**/ant.jar&quot;/&gt;
  167. &lt;/fileset&gt;
  168. &lt;/move&gt;
  169. </pre>
  170. <p><b>Append <code>&quot;.bak&quot;</code> to the names of all files
  171. in a directory.</b></p>
  172. <pre>
  173. &lt;move todir=&quot;my/src/dir&quot; includeemptydirs=&quot;false&quot;&gt;
  174. &lt;fileset dir=&quot;my/src/dir&quot;&gt;
  175. &lt;exclude name=&quot;**/*.bak&quot;/&gt;
  176. &lt;/fileset&gt;
  177. &lt;mapper type=&quot;glob&quot; from=&quot;*&quot; to=&quot;*.bak&quot;/&gt;
  178. &lt;/move&gt;
  179. </pre>
  180. <hr>
  181. <p align="center">Copyright &copy; 2000-2004 The Apache Software Foundation. All rights
  182. Reserved.</p>
  183. </body>
  184. </html>