Search code examples
nant

Copy only modified and new files from source to destination in nant script


Currently we are using copy command to copy files from one location to other, but it is coping all files over and again. Here I want to copy only modified and new files from source to destination.

Can any one please help me in this?

Here is sample code:

<copy overwrite="true" todir="destination">
      <fileset basedir="source">
        <include name="**/*"/>
      </fileset>
    </copy>

Solution

  • This would copy only modified files from source folder to destination folder:

    <exec program="C:\Windows\System32\xcopy.exe" failonerror="false" >
      <arg line="${source} ${destination} /D /E /C /Q /H /R /Y /K" />
    </exec>