ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jack Blan <>
Subject Using regular expressions to select files when using ant copy task
Date Tue, 23 Jun 2009 20:42:15 GMT


I have 'src' folder and a 'dest' folder.  The 'src' folder has the following
1) ans_key.tif
2) arrow.tif
3) eqn_y=x+1.tif
4) re teach.tif
5) ab+cd.tif

I want to copy all files that conform to a naming convention to 'dest'
folder.  The rules are simple: only allowed characters in file names are
a-z, A-Z, 0-9, dash(-), underscore(_) and period(.).  Which means, I want
only files 1 and 2 to be copied over to 'dest'.  For this purpose, I wrote
the following build.xml:

<project name="name of project" default="copy_graphics" basedir=".">
    <target name="copy_graphics" description="Copy Graphics">
	<copy overwrite="true" todir="dest">
	    <fileset dir="src" includes="**/*.tif">
	    	<containsregexp expression="^[a-zA-Z0-9\._-]+$"/>

But it didn't work.  What's more confusing is except for file 2 (arrow.tif
), all others get copied.  

I read in one of the forums that <containsregexp> looks in the content
rather than the filename.  So I tried playing around various combinations
	    <fileset dir="src">
	    	<filename name="**/^[a-zA-Z0-9\._-]+\.tif$"/>

That didn't work either.  Can anybody please help?

View this message in context:
Sent from the Ant - Users mailing list archive at

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

View raw message