Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ant: Change extension on file

Status
Not open for further replies.

mdoland

Programmer
Nov 3, 2003
2
SE
I have an exec in Ant that looks like this:

<exec taskname = "convert"
executable = "convert"
failonerror = "true">
<arg line="in=@{file} out=???" />
</exec>

I want to use a command that converts a file. THe in infile name has one extension and the out file another, but the rest of the file name should be the same. How do I get it this way?

The arg line is messed up since I don't know what to write.
 
... and which o/s is that intended for?

Tim
 
Primarily Windows, but it could be for Linux later on.
 
Sorry have not tested this, but, this should copy all files in c:\myindir with a ".sqlx" extension to c:\myoutdir, changing the extension to ".sql". This should work on windows/unix.Let me know if you are still having problems! And remember all this stuff is in the online manual!

<project name="copyfilechangesuffix" default="main">
<target name="main">
<copy filtering="true" todir="c:\myoutdir">
<fileset dir="c:\myindir" />
<mapper>
<globmapper from="*.sqlx" to="*.sql" />
</mapper>
</copy>
</target>
</project>
 
Tested now works OK in windows XP and in unix (well CYGWIN on an XP box)!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top