NAnt SDK Documentation - v0.92

MoveTask Class

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

For a list of all members of this type, see MoveTask Members.

System.Object
   NAnt.Core.Element
      NAnt.Core.Task
         NAnt.Core.Tasks.CopyTask
            NAnt.Core.Tasks.MoveTask

[Visual Basic]
<TaskName(Name:="move")>
Public Class MoveTask
    Inherits CopyTask
[C#]
[TaskName(Name="move")]
public class MoveTask : CopyTask

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

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:

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 ToDirectory 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.

Example

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

Namespace: NAnt.Core.Tasks

Assembly: NAnt.Core (in NAnt.Core.dll)

See Also

MoveTask Members | NAnt.Core.Tasks Namespace