Search code examples
antscriptingsalesforcesfdc-migration-tool

How to copy all the files modified today using ANT script?


I have below script which will give me number of files mentioned in my "count" field. What I want is to get all the files that were modified today.

<project name="copy latest files test" basedir="." xmlns:sf="antlib:com.salesforce">
<taskdef resource="net/sf/antcontrib/antlib.xml">
 <classpath>
 <pathelement location="C:/apache-ant-1.9.6/lib/ant-contrib-1.0b3.jar"/>
 </classpath>
</taskdef>
<!-- Create sub folder called classes -->
    <target name="createClassesFolder">
      <mkdir dir="tempFolder/classes"/>
    </target>
<!-- Copy contents of classes folder from source folder -->
    <target name="moveClassesFolder" depends="createClassesFolder">
		<copy toDir="tempFolder/classes" preservelastmodified="true">
			  <last count="2">
			  <sort>
			  <date xmlns="antlib:org.apache.tools.ant.types.resources.comparators"/>
			  <resources>
			  <fileset dir="retrieveUnpackaged/classes"/>
			  </resources>
			  </sort>
			  </last>
		</copy>

    </target>
</project>

I also want to get .xml file of the same files that were copied during the process. The reason to get .xml file is to use ANT migration tool once I have everything in other directory. How do I achieve that? Any help would be greatly appreciated.


Solution

  • I found a solution to this. Below is the ANT script.

    <property name="src.dir" value="retrieveUnpackaged"/>
    <property name="dest.dir" value="tempFolder"/>
    
    <target name="moveFolders" >
        <copy toDir="${dest.dir}">        
              <fileset dir="${src.dir}">
                <include name="*/**"/>              
                <date datetime="04/20/2016 10:35 AM" when="after"/>
              </fileset>      
        </copy>