ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lars Monsees" <>
Subject How can I pass each filename of a fileset to a macrodef?
Date Tue, 15 Jul 2008 15:59:55 GMT

I couldn´t find a better subject for describing the problem that I have. It seems quite tricky
to me...

I have a directory with multiple files of which I don´t know the exact names like this:


As you can see, there are pairs of files (.order and .pdf) with the id "yo....".
I want to move each of these pairs into a sub-dir with the name of the id:

   |-- 1234
   |   |
   |   |-- yo1234.order
   |   |-- 8211_020_yo1234.pdf
   |-- 1236
       |-- yo1236.order
       |-- 8211_040_yo1236.pdf

I´ve got everything working when I enter the filename to use manually (s. property "todo"
in XML below).
I guess, I have to put all the actions into a macrodef and pass the filename as a parameter.

I would enumerate all the files in that dir with a fileset, but how can I go through that
enum and pass each filename to the macrodef???


   <target name="Main" description="Moves files into appropriate folders">
    	<!-- create folder with current date -->
    	<mkdir dir="${dir.source}/${DSTAMP}"/>

    	<!-- Get order number from file -->
    	<property name="todo" value="yo1234.order"/>

    	<loadfile property="order.number" srcFile="${dir.source}/${todo}">
                    <contains value="${order.marker}"/>
	        	<replacestring from="${order.marker}" to=""/>
        <!-- Create sub-folder for specific order -->
        <mkdir dir="${dir.source}/${DSTAMP}/${order.number}"/>
        <!-- Move order into sub-folder -->
        <move todir="${dir.source}/${DSTAMP}/${order.number}">
        	<fileset dir="${dir.source}">
        	    <include name="*${order.number}.*"/>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message