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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ant Script timestamp backup?

Status
Not open for further replies.

sk8ology

IS-IT--Management
May 14, 2004
64
US
I'm trying to create backups of files we are getting from a client. They come to us like fileABC1000I. We have an ANT script that manipulates the data but before this within in the same script I want to backup the file with a timestamp in the filename. The programmer that developed the ant script isn't around anymore. To test this out I created a small ant script (that doesn't work);
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="bak">
<property file="conf/build.properties" />
<property file="conf/user.properties" />
<target name="bak">
<tstamp/>
<move file="ImportNEW/fileABC1*" tofile="ImportNEW/backup/fileABC1{$DSTAMP}.BAK"/>
<move file="ImportNEW/fileABC2*" tofile="ImportNEW/backup/fileABC2{$DSTAMP}.BAK"/>
<move file="ImportNEW/fileABC3*" tofile="ImportNEW/backup/fileABC3{$DSTAMP}.BAK"/>
<move file="ImportNEW/fileABC4*" tofile="ImportNEW/backup/fileABC4{$DSTAMP}.BAK"/>
</target>
</project>

I think I'm on the right track but it's not working? Can someone help?
 
Awesome!! Thanks! It worked when I took out the wild card. When I left it in it said Warning: Could not find file d:\ImportNEW\fileABC1* to copy. The files I need to backup don't change names but others do. Why isn't it recognizing the wild card?
 
Might be a problem with case sensitive filenames? I can't find any mention of that on the plain <move> task ( but an embed <fileset> ( can have the casesensitive="false" setting to avoid these issues. But this will introduce some complexity, as the <fileset> can only return a single result when using the 'tofile' parameter on <move>...

Or maybe just adjust the casing in your script?

HTH
TonHu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top