back up folder and always having 7 folders using ANT -
i have requirements ant script.
my ant script checking out of "mobile"
folder version control software "nightly build"
folder , have requirements:
if inside
"nightly build"
folder, there exist folder"mobile"
folder, want older folder renaming folder"mobile" + timestamp
"nightly build"
folder should contain 7 such"mobile"
folders only. means if there 8"mobile"
, need delete oldest"mobile"
folder
is possible in ant script(performed sequentially) , how do it?
suggestion - deletes more 7 days old, rather keeping fixed number of builds.
<property name="builds.dir" value="nightly build" /> <property name="build.dir" value="mobile" /> <tstamp> <format property="cutoff.7" offset="-7" unit="day" pattern="mm/dd/yyyy hh:mm aa"/> </tstamp> <tstamp> <format property="suffix" pattern="yyyymmddhhmmss"/> </tstamp> <move file="${builds.dir}/${build.dir}" tofile="${builds.dir}/${build.dir}.${suffix}" failonerror="false" /> <delete> <dirset dir="${builds.dir}" id="old.dirs" includes="${build.dir}.*"> <date datetime="${cutoff.7}" when="before" checkdirs="yes" /> </dirset> </delete> </project>
see ant tstamp
task , selectors more details.
Comments
Post a Comment