antechofileset

How to console output all files from selected fileset?


I just started working with Ant scripts so i'm not sure I'm asking the correct question but here it goes:

I have a script that is suppose to find a RegEx pattern from individual files on a specified directory and replace it, but I want to output a list of the selected files on the console.

I have successfully created the script to search and replace with no issues and I already know the amount of files changed (just under 5000 files). Now I'm trying to output the list of files but the amount of files shown in the console is considerably less (just under 600 files). I'm not sure if it's just that the number of files is too high to output on the console or my script needs work

Here is the code I have to output my results:

    <target name="find">
        <path id="find.path">
            <fileset dir="${custom.dir}">
                <include name="**/*.js"/>
                <include name="**/*.jsp"/>
                <include name="**/*.xml"/>
                <include name="**/*.css"/>
                <include name="**/*.java"/>
                <containsregexp expression="(YEAR|DATE)(?:\s*2016,\s)"/>
            </fileset>
        </path>
        <pathconvert pathsep="${line.separator}--> "             
                property="echo.path.compile"             
                refid="find.path">
        </pathconvert>
        <echo>${echo.path.compile}</echo>
    </target>

Solution

  • Assuming the XML file for your Ant is find.xml which has the above code you provided and the custom.dir for your files is /Desktop/Files.

    Here are the steps using Bash shell:

    1. Create a file named find.sh in the same directory of your find.xml

    2. Inside the file.sh put the following (you CAN NOT use the ${custom.dir} as reference in the code below):

      for f in /Desktop/Files/*; do 
        echo $f;
        ant -f find.xml find;
      done 
      

    what this does is it loops through every file in the files directory no matter the extension is, it echo the file name with its location and then executes the find.xml with target find.

    You run the find.sh file from Terminal like ./find.sh.