ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lars Monsees" <l.mons...@atlantisgmbh.de>
Subject RE: How can I pass each filename of a fileset to a macrodef?
Date Wed, 16 Jul 2008 09:19:38 GMT
Thx, that works fine =)

Usage examples (I couldn´t find them in ant-contrib) are here:
http://www.loribel.com/info/memento/ant.html (french)


Lars


> ant-contrib <for> sounds like what you want.
> 
> HTH,
> Matt
> 
> --- Lars Monsees <l.monsees@atlantisgmbh.de> wrote:
> 
>> Hi,
>> 
>> 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:
>> 
>>    yo1234.order
>>    yo1236.order
>>    8211_020_yo1234.pdf
>>    8211_040_yo1236.pdf
>> 
>> 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???
>> 
>> 
>> Lars
>> 
>> 
>> 
>>    <target name="Main" description="Moves files into appropriate
>>     	folders"> <!-- create folder with current date -->
>>     	<tstamp/>
>>     	<mkdir dir="${dir.source}/${DSTAMP}"/>
>> 
>>     	<!-- Get order number from file -->
>>     	<property name="todo" value="yo1234.order"/>
>> 
>>     	<loadfile property="order.number"
>> srcFile="${dir.source}/${todo}">
>> 	        <filterchain>
>>                 <linecontains>
>>                     <contains
>> value="${order.marker}"/>
>>                 </linecontains>
>> 	        	<replacestring from="${order.marker}"
>> to=""/>
>> 	        	<trim/>
>> 	            <striplinebreaks/>
>> 	        </filterchain>
>> 	    </loadfile>
>> 
>>         <!-- 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}.*"/>
>>     	    </fileset>
>>     	</move>
>> 
>>     </target>
>> 
>> 
> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> user-unsubscribe@ant.apache.org
>> For additional commands, e-mail:
>> user-help@ant.apache.org
>> 
>> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message