<move> Task

# <move>

Moves a file, a directory, or set of files to a new file or directory.

Files are only moved if the source file is newer than the destination file, or if the destination file does not exist. However, you can explicitly overwrite files with the `overwrite` attribute.

Entire directory structures can be moved to a new location. For this to happen, the following criteria must be met:

- Everything in the fileset is included
- The directory structure is not flattened
- Empty directories are included
- Destination directory does not exist

If any of these items are not met, then the files within the source directory will be moved over instead of the entire directory structure.

A <fileset> can be used to select files or directories to move. To use a <fileset>, the `todir` attribute must be set.

### Encoding

Unless an encoding is specified, the encoding associated with the system's current ANSI code page is used.

An UTF-8, little-endian Unicode, and big-endian Unicode encoded text file is automatically recognized, if the file starts with the appropriate byte order marks.

Note: If you employ filters in your move operation, you should limit the move to text files. Binary files will be corrupted by the move operation.

### Parameters

Attribute | Type | Description | Required
--- | --- | --- | ---
file | file | The file to move. | False
flatten | bool | Ignore directory structure of source directory, move all files into a single directory, specified by the `todir` attribute. The default is false. | False
todir | directory | The directory to move to. | False
tofile | file | The file to move to. | False
failonerror | bool | Determines if task failure stops the build, or is just reported. The default is true. | False
if | bool | If true then the task will be executed; otherwise, skipped. The default is true. | False
includeemptydirs | bool | Copy any empty directories included in the <fileset>. The default is true. | False
inputencoding | Encoding | The encoding to use when reading files. The default is the system's current ANSI code page. | False
outputencoding | Encoding | The encoding to use when writing the files. The default is the encoding of the input file. | False
overwrite | bool | Overwrite existing files even if the destination files are newer. The default is false. | False
unless | bool | Opposite of `if`. If false then the task will be executed; otherwise, skipped. The default is false. | False
verbose | bool | Determines whether the task should report detailed build log messages. The default is false. | False

### Nested Elements:

#### <fileset>

Used to select the files to move. To use a <fileset>, the `todir` attribute must be set.

#### </fileset>

#### <filterchain>

Chain of filters used to alter the file's content as it is moved.

#### </filterchain>

### Examples

- Move a single file while changing its encoding from "latin1" to "utf-8".

      <move
          file="myfile.txt"
          tofile="mycopy.txt"
          inputencoding="latin1"
          outputencoding="utf-8" />

- Move a set of files.

      <move todir="${build.dir}">
          <fileset basedir="bin">
              <include name="*.dll" />
          </fileset>
      </move>

- Move a set of files to a directory, replacing `@TITLE@` with "Foo Bar" in all files.

      <move todir="../backup/dir">
          <fileset basedir="src_dir">
              <include name="**/*" />
          </fileset>
          <filterchain>
              <replacetokens>
                  <token key="TITLE" value="Foo Bar" />
              </replacetokens>
          </filterchain>
      </move>

- Move an entire directory and its contents.

      <move todir="target/dir">
        <fileset basedir="source/dir"/>
      </move>

### Requirements

Assembly: NAnt.Core (0.92.4543.0)