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 4.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Apache Ant User Manual</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. <h3>Parameters</h3>
  17. <table border="1" cellpadding="2" cellspacing="0">
  18. <tr>
  19. <td valign="top"><b>Attribute</b></td>
  20. <td valign="top"><b>Description</b></td>
  21. <td align="center" valign="top"><b>Required</b></td>
  22. </tr>
  23. <tr>
  24. <td valign="top">file</td>
  25. <td valign="top">the file to move</td>
  26. <td valign="top" align="center">One of <var>file</var> or
  27. at least one nested fileset element</td>
  28. </tr>
  29. <tr>
  30. <td valign="top">tofile</td>
  31. <td valign="top">the file to move to</td>
  32. <td valign="top" align="center" rowspan="2">With the <var>file</var> attribute,
  33. either <var>tofile</var> or <var>todir</var> can be used. With nested filesets,
  34. if the fileset size is greater than 1 or if the only entry in the fileset is a
  35. directory or if the <var>file</var> attribute is already specified, only
  36. <var>todir</var> is allowed</td>
  37. </tr>
  38. <tr>
  39. <td valign="top">todir</td>
  40. <td valign="top">the directory to move to</td>
  41. </tr>
  42. <tr>
  43. <td valign="top">overwrite</td>
  44. <td valign="top">overwrite existing files even if the destination
  45. files are newer (default is &quot;true&quot;)</td>
  46. <td valign="top" align="center">No</td>
  47. </tr>
  48. <tr>
  49. <td valign="top">filtering</td>
  50. <td valign="top">indicates whether token filtering should take place during
  51. the move. See the <a href="filter.html">filter</a> task for a description of
  52. how filters work.</td>
  53. <td valign="top" align="center">No</td>
  54. </tr>
  55. <tr>
  56. <td valign="top">flatten</td>
  57. <td valign="top">ignore directory structure of source directory,
  58. copy all files into a single directory, specified by the <var>todir</var>
  59. attribute (default is &quot;false&quot;).Note that you can achieve the
  60. same effect by using a <a href="../CoreTypes/mapper.html#flatten-mapper">flatten mapper</a></td>
  61. <td valign="top" align="center">No</td>
  62. </tr>
  63. <tr>
  64. <td valign="top">includeEmptyDirs</td>
  65. <td valign="top">Copy empty directories included with the nested FileSet(s).
  66. Defaults to &quot;yes&quot;.</td>
  67. <td valign="top" align="center">No</td>
  68. </tr>
  69. </table>
  70. <h3>Parameters specified as nested elements</h3>
  71. <h4>mapper</h4>
  72. <p>You can define file name transformations by using a nested <a
  73. href="../CoreTypes/mapper.html">mapper</a> element. The default mapper used by
  74. <code>&lt;copy&gt;</code> is the <a
  75. href="../CoreTypes/mapper.html#identity-mapper">identity</a>.</p>
  76. <h3>Examples</h3>
  77. <p><b>Move a single file (rename a file)</b></p>
  78. <pre>
  79. &lt;move file=&quot;file.orig&quot; tofile=&quot;file.moved&quot;/&gt;
  80. </pre>
  81. <p><b>Move a single file to a directory</b></p>
  82. <pre>
  83. &lt;move file=&quot;file.orig&quot; todir=&quot;dir/to/move/to&quot;/&gt;
  84. </pre>
  85. <p><b>Move a directory to a new directory</b></p>
  86. <pre>
  87. &lt;move todir=&quot;new/dir/to/move/to&quot;&gt;
  88. &lt;fileset dir=&quot;src/dir&quot;/&gt;
  89. &lt;/move&gt;
  90. </pre>
  91. <p><b>Move a set of files to a new directory</b></p>
  92. <pre>
  93. &lt;move todir=&quot;some/new/dir&quot; &gt;
  94. &lt;fileset dir=&quot;my/src/dir&quot; &gt;
  95. &lt;include name=&quot;**/*.jar&quot;/&gt;
  96. &lt;exclude name=&quot;**/ant.jar&quot;/&gt;
  97. &lt;/fileset&gt;
  98. &lt;/move&gt;
  99. </pre>
  100. <p><b>Append <code>&quot;.bak&quot;</code> to the names of all files
  101. in a directory.</b></p>
  102. <pre>
  103. &lt;move todir=&quot;my/src/dir&quot; &gt;
  104. &lt;fileset dir=&quot;my/src/dir&quot; &gt;
  105. &lt;exclude name=&quot;**/*.bak&quot;/&gt;
  106. &lt;/fileset&gt;
  107. &lt;mapper type=&quot;glob&quot; from=&quot;*&quot; to=&quot;*.bak&quot;/&gt;
  108. &lt;/move&gt;
  109. </pre>
  110. <hr>
  111. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  112. Reserved.</p>
  113. </body>
  114. </html>