You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by arunks <ar...@galileo.com> on 2007/10/23 22:00:28 UTC

Ant Delete task - Deleting a file from a directory while comparing from another directory

Hi All,

Can someone please let me know, whether the ANT code below is good or- what
it will do.

I have 3 files in backup.dir folder and 3+1 extra file in release.dir
folder. The 1 extra file inside release.dir folder is a new file added to
the release folder (patching) before running the code below. 

Now (for unpatching that new file), I want to write a code that should
compare the files between backup.dir and release.dir folders…and it should
pick the new file and say that oh!!! This is the new file and for
un-patching it I have to remove that new file from the release.dir folder
and then I’ll move the file’s from backup.dir folder to release.dir again
(so that the old changes will get placed on runtime release.dir folder
again, see code in Green color, I know that it’s perfect, but I want your
suggestions for removing a file from release.dir if that file/s has/have
been added to release.dir folder recently and considered as new file/s. So
for this, see RED lines below and let me know what it will do, whether it is
a correct code, or how can I achieve my goal). 

     65     <delete>
     66       <fileset dir="${release.dir}">
     67       <present present="srconly" targetdir="${backup.dir}"/>
     68       <include name="**/*"/>
     69     </delete>

     71     <move todir="${release.dir}">
     72       <fileset dir="${backup.dir}">
     73         <include name="**/*"/>
     74       </fileset>
     75     </move>

Brgds,
Arun Sangal
SCM   1 - (303) 397 6059
arun.sangal@galileo.com

-- 
View this message in context: http://www.nabble.com/Ant-Delete-task---Deleting-a-file-from-a-directory-while-comparing-from-another-directory-tf4679976.html#a13372424
Sent from the Ant - Users mailing list archive at Nabble.com.


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


RE: Ant Delete task - Deleting a file from a directory while comparing from another directory

Posted by "Sangal, Arun" <Ar...@galileo.com>.
Thanks David for putting light on it. Well, here is my actual >>>> ?

I have to do the following task:
1) I have 5 files to patch at release folder (or you can say runtime
folder).
2) 4 files already exist at runtime with version 1.4 
3) The files I'm going to patch is having 4 files (with version 1.5) and
1 new file with 
   version 1.1. These 5 files are stored inside ${patch.dir} folder.

4) Now, Patching is working file. After the patching gets complete,
script first creates 
   a backup folder (excluding the new file as it's was not present
before patching). 
   This folder is stored at ${backup.dir} location. And as I said
patching is working   
   Fine, I'm seeing version 1.5 for the existing 4 files and the new
file also gets 
   patched there at release/runtime folder. 

   ***** Till this point everything is working OK ******

5) Now, what if someone tells me to unpatch what I have done????
6) My steps would be:
   a) Place the files from backup folder again at runtime (i.e. 4 files
will again 
      get the same old copy of version 1.4)
   b) Remove if there is any new files/folders that have been added
during patch step.
      (here in this case, I have to remove only that single newly added
file to the 
        patch folder having version 1.1 from the release folder). If
this happens, 
      release folder will become same as it was before we started
patching task.

7) NOW, what code shall I write that will compare backup and patch
folder and if it finds a file in patch folder that is not present in
backup folder (means it's a totally new file meant to be inserted in the
release folder), then it should pick that file/s// folder/s and remove
it from the release folder ??????????????????

The latest code I have written in the patch/unpatch script is as follows
for doing the step 6c =or= 7th.

    <delete dir="${release.dir}">
      <fileset dir="${patch.dir}">
        <present present="srconly" targetdir="${backup.dir}"/>
        <include name="**/*"/>
      </fileset>
      <echo message="New files/folders applied during the patching step
have been removed now from release folder!"/>
      <echo
message="----------------------------------------------------------"/>
    </delete>


Kindly help or let me know, in case you need more clarification.
Thanks-

Brgds,
Arun Sangal
SCM   1 - (303) 397 6059
arun.sangal@galileo.com


-----Original Message-----
From: David Weintraub [mailto:qazwart@gmail.com] 
Sent: Tuesday, October 23, 2007 3:28 PM
To: Ant Users List
Subject: Re: Ant Delete task - Deleting a file from a directory while
comparing from another directory

Bold? Red?

Unfortunately, like most mailing lists, this is a text only list.
You'll have to point out the line numbers that you have questions
about, and where in the line. Also remember that not everyone uses
monospaced fonts (stupid Gmail!), so you can't depend upon line
spacing to help point out the error either.

It looks like you ask it to delete files only if the file is found in
the ${release.dir}, but not in the ${backup.dir}. Is this correct?

Then, it moves all the files from ${release.dir} to ${backup.dir}.

My only issue is that if there is a new file, you're not moving it to
backup.dir.


On 10/23/07, arunks <ar...@galileo.com> wrote:
>
> Hi All,
>
> Can someone please let me know, whether the ANT code below is good or-
what
> it will do.
>
> I have 3 files in backup.dir folder and 3+1 extra file in release.dir
> folder. The 1 extra file inside release.dir folder is a new file added
to
> the release folder (patching) before running the code below.
>
> Now (for unpatching that new file), I want to write a code that should
> compare the files between backup.dir and release.dir folders...and it
should
> pick the new file and say that oh!!! This is the new file and for
> un-patching it I have to remove that new file from the release.dir
folder
> and then I'll move the file's from backup.dir folder to release.dir
again
> (so that the old changes will get placed on runtime release.dir folder
> again, see code in Italic font, I know that it's perfect. But I want
your
> suggestions for removing a file from release.dir if that file/s
has/have
> been added to release.dir folder recently and considered as new
file/s. So
> for this, see lines in BOLD font below and let me know what it will
do,
> whether it is a correct code, or how can I achieve my goal).
>
>      65     <delete>
>      66       <fileset dir="${release.dir}">
>      67       <present present="srconly" targetdir="${backup.dir}"/>
>      68       <include name="**/*"/>
>      69     </delete>
>
>      71     <move todir="${release.dir}">
>      72       <fileset dir="${backup.dir}">
>      73         <include name="**/*"/>
>      74       </fileset>
>      75     </move>
>
> Brgds,
> Arun Sangal
> SCM   1 - (303) 397 6059
> arun.sangal@galileo.com
>
> --
> View this message in context:
http://www.nabble.com/Ant-Delete-task---Deleting-a-file-from-a-directory
-while-comparing-from-another-directory-tf4679976.html#a13372424
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 
--
David Weintraub
qazwart@gmail.com

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

The information in this electronic mail message is sender's 
business Confidential and may be legally privileged.  It is 
intended solely for the addressee(s).  Access to this Internet 
electronic mail message by anyone else is unauthorized.  If 
you are not the intended recipient, any disclosure, copying, 
distribution or any action taken or omitted to be taken in 
reliance on it is prohibited and may be unlawful. The sender 
believes that this E-mail and any attachments were free of 
any virus, worm, Trojan horse, and/or malicious code when 
sent. This message and its attachments could have been 
infected during  transmission. By reading the message and 
opening any attachments, the recipient accepts full responsibility for taking protective and remedial action about 
viruses and other defects. Travelport Inc. is not liable for any loss or damage arising in any way from this message or its 
attachments.


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


Re: Ant Delete task - Deleting a file from a directory while comparing from another directory

Posted by David Weintraub <qa...@gmail.com>.
Bold? Red?

Unfortunately, like most mailing lists, this is a text only list.
You'll have to point out the line numbers that you have questions
about, and where in the line. Also remember that not everyone uses
monospaced fonts (stupid Gmail!), so you can't depend upon line
spacing to help point out the error either.

It looks like you ask it to delete files only if the file is found in
the ${release.dir}, but not in the ${backup.dir}. Is this correct?

Then, it moves all the files from ${release.dir} to ${backup.dir}.

My only issue is that if there is a new file, you're not moving it to
backup.dir.


On 10/23/07, arunks <ar...@galileo.com> wrote:
>
> Hi All,
>
> Can someone please let me know, whether the ANT code below is good or- what
> it will do.
>
> I have 3 files in backup.dir folder and 3+1 extra file in release.dir
> folder. The 1 extra file inside release.dir folder is a new file added to
> the release folder (patching) before running the code below.
>
> Now (for unpatching that new file), I want to write a code that should
> compare the files between backup.dir and release.dir folders…and it should
> pick the new file and say that oh!!! This is the new file and for
> un-patching it I have to remove that new file from the release.dir folder
> and then I'll move the file's from backup.dir folder to release.dir again
> (so that the old changes will get placed on runtime release.dir folder
> again, see code in Italic font, I know that it's perfect. But I want your
> suggestions for removing a file from release.dir if that file/s has/have
> been added to release.dir folder recently and considered as new file/s. So
> for this, see lines in BOLD font below and let me know what it will do,
> whether it is a correct code, or how can I achieve my goal).
>
>      65     <delete>
>      66       <fileset dir="${release.dir}">
>      67       <present present="srconly" targetdir="${backup.dir}"/>
>      68       <include name="**/*"/>
>      69     </delete>
>
>      71     <move todir="${release.dir}">
>      72       <fileset dir="${backup.dir}">
>      73         <include name="**/*"/>
>      74       </fileset>
>      75     </move>
>
> Brgds,
> Arun Sangal
> SCM   1 - (303) 397 6059
> arun.sangal@galileo.com
>
> --
> View this message in context: http://www.nabble.com/Ant-Delete-task---Deleting-a-file-from-a-directory-while-comparing-from-another-directory-tf4679976.html#a13372424
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 
--
David Weintraub
qazwart@gmail.com

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