Skip to content

Instantly share code, notes, and snippets.

@suzuki
Created March 26, 2012 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suzuki/2203147 to your computer and use it in GitHub Desktop.
Save suzuki/2203147 to your computer and use it in GitHub Desktop.
Sorted filelist for Phing
<?xml version="1.0" encoding="utf-8" ?>
<project name="sorted-filelist" basedir="." default="all">
<target name="all" depends="use-fileset, use-find" />
<!-- fileset version -->
<!-- no sort -->
<target name="use-fileset">
<foreach param="filename" target="echo-filename">
<fileset dir="./testdir">
<include name="*.txt" />
</fileset>
</foreach>
</target>
<!-- find version -->
<!-- sorted ! -->
<target name="use-find">
<exec command="find ./testdir -name '*.txt' | sort | xargs -n 1 basename | tr '\n' ',' > /tmp/filelist" />
<loadfile property="file-list" file="/tmp/filelist" />
<foreach list="${file-list}" param="filename" target="echo-filename" />
</target>
<target name="echo-filename">
<echo msg="Filename is ${filename}" />
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment