You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Rohit P <ro...@gmail.com> on 2008/11/03 12:45:09 UTC

Under a parent directory delete only 4 out of 6 child directories [non-empty]

Hi,
I have a directory "Parent" containing 6 "child" directories with files.I
have a task of deleting only 4 "child" directories with their files.
I tried 2 approaches in getting this done. But couldn't accomplish.

Approach 1:

<project name="Check Deletion task" basedir="." default="main">

    <target name="main">
        <delete>
            <fileset dir="C:\Rootdir\Maindir\Parent" excludes="**\child 1\*,
**\child 2\*, **\child5\*, **\child6\*"/>
        </delete>
    </target>
</project>

Result: This action deleted only the files under the child directories

Approach 2:

<project name="Check Deletion task" basedir="." default="main">

    <target name="main">
        <delete>
            <fileset dir="C:\Rootdir\Maindir\Parent\child 1"/>
            <fileset dir="C:\Rootdir\Maindir\Parent\child 2"/>
            <fileset dir="C:\Rootdir\Maindir\Parent\child5"/>
            <fileset dir="C:\Rootdir\Maindir\Parent\child6"/>
        </delete>
    </target>
</project>

Result: Same as approach 1 deleted all the files under respective child
directories.

Can anybody suggest me how to delete only 4 child directories and their
files?

Thanks A Ton
Rohit

Re: Under a parent directory delete only 4 out of 6 child directories [non-empty]

Posted by Mark Salter <ma...@talktalk.net>.
Rohit P wrote:
> Hi,
> I have a directory "Parent" containing 6 "child" directories with files.I
> have a task of deleting only 4 "child" directories with their files.
The second example in the manual does (I think) give you the answer you
need:-

	http://ant.apache.org/manual/CoreTasks/delete.html

So for your child deletions...

<project name="Check Deletion task" basedir="." default="main">

    <target name="main">
        <delete dir="C:\Rootdir\Maindir\Child 1"/>
        <delete dir="C:\Rootdir\Maindir\Child 2"/>
        <delete dir="C:\Rootdir\Maindir\Child5"/>
        <delete dir="C:\Rootdir\Maindir\Child6"/>
    </target>
</project>


Is that what you wanted?

-- 
Mark

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


Re: Under a parent directory delete only 4 out of 6 child directories [non-empty]

Posted by Rohit P <ro...@gmail.com>.
Thanks Gilbert.
I could use your solution and achieve the logic i was looking for.

Thanks A Ton
Rohit

On Tue, Nov 4, 2008 at 2:00 PM, Rebhan, Gilbert <
Gilbert.Rebhan@huk-coburg.de> wrote:

>
> -----Original Message-----
> From: Rohit P [mailto:rohitmp.for@gmail.com]
> Sent: Tuesday, November 04, 2008 5:42 AM
> To: Ant Users List
> Subject: Re: Under a parent directory delete only 4 out of 6 child
> directories [non-empty]
>
> /*
> Actually i would like to delete the child directories by using only once
> parent directory. Something similar to deleting set of only .java files
> under sub-directories.
> Hence i considered task like <fileset>, instead of directly deleting the
> child directories one after the other.
> */
>
> use a pattern for the directories that should get deleted, something like =
>
> <delete includeemptydirs="true" verbose="true">
>  <fileset dir="/your/root/dir" defaultexcludes="false">
>  <include name="**/yourpattern/**" />
>  </fileset>
> </delete>
>
> Regards, Gilbert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

RE: Under a parent directory delete only 4 out of 6 child directories [non-empty]

Posted by "Rebhan, Gilbert" <Gi...@huk-coburg.de>.
-----Original Message-----
From: Rohit P [mailto:rohitmp.for@gmail.com]
Sent: Tuesday, November 04, 2008 5:42 AM
To: Ant Users List
Subject: Re: Under a parent directory delete only 4 out of 6 child directories [non-empty]

/*
Actually i would like to delete the child directories by using only once
parent directory. Something similar to deleting set of only .java files
under sub-directories.
Hence i considered task like <fileset>, instead of directly deleting the
child directories one after the other.
*/

use a pattern for the directories that should get deleted, something like =

<delete includeemptydirs="true" verbose="true">
 <fileset dir="/your/root/dir" defaultexcludes="false">
  <include name="**/yourpattern/**" />
 </fileset>
</delete>

Regards, Gilbert

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


Re: Under a parent directory delete only 4 out of 6 child directories [non-empty]

Posted by Rohit P <ro...@gmail.com>.
Thanks for the suggestions.

Actually i would like to delete the child directories by using only once
parent directory. Something similar to deleting set of only .java files
under sub-directories.
Hence i considered task like <fileset>, instead of directly deleting the
child directories one after the other.

If you know or have encountered such situation please let me know how you
resolved it.

Thanks A Ton
Rohit

On Tue, Nov 4, 2008 at 5:34 AM, David Weintraub <qa...@gmail.com> wrote:

> Have you tried setting the "includeemptydirs" parameter in the delete
> task to true?
>
> That will also delete any directory that is actually empty once the
> files are deleted.
>
> You can also try <dirset> instead of <fileset>.
>
> --
> David Weintraub
> qazwart@gmail.com
>
>
>
> On Mon, Nov 3, 2008 at 6:45 AM, Rohit P <ro...@gmail.com> wrote:
> > Hi,
> > I have a directory "Parent" containing 6 "child" directories with files.I
> > have a task of deleting only 4 "child" directories with their files.
> > I tried 2 approaches in getting this done. But couldn't accomplish.
> >
> > Approach 1:
> >
> > <project name="Check Deletion task" basedir="." default="main">
> >
> >    <target name="main">
> >        <delete>
> >            <fileset dir="C:\Rootdir\Maindir\Parent" excludes="**\child
> 1\*,
> > **\child 2\*, **\child5\*, **\child6\*"/>
> >        </delete>
> >    </target>
> > </project>
> >
> > Result: This action deleted only the files under the child directories
> >
> > Approach 2:
> >
> > <project name="Check Deletion task" basedir="." default="main">
> >
> >    <target name="main">
> >        <delete>
> >            <fileset dir="C:\Rootdir\Maindir\Parent\child 1"/>
> >            <fileset dir="C:\Rootdir\Maindir\Parent\child 2"/>
> >            <fileset dir="C:\Rootdir\Maindir\Parent\child5"/>
> >            <fileset dir="C:\Rootdir\Maindir\Parent\child6"/>
> >        </delete>
> >    </target>
> > </project>
> >
> > Result: Same as approach 1 deleted all the files under respective child
> > directories.
> >
> > Can anybody suggest me how to delete only 4 child directories and their
> > files?
> >
> > Thanks A Ton
> > Rohit
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

Re: Under a parent directory delete only 4 out of 6 child directories [non-empty]

Posted by David Weintraub <qa...@gmail.com>.
Have you tried setting the "includeemptydirs" parameter in the delete
task to true?

That will also delete any directory that is actually empty once the
files are deleted.

You can also try <dirset> instead of <fileset>.

--
David Weintraub
qazwart@gmail.com



On Mon, Nov 3, 2008 at 6:45 AM, Rohit P <ro...@gmail.com> wrote:
> Hi,
> I have a directory "Parent" containing 6 "child" directories with files.I
> have a task of deleting only 4 "child" directories with their files.
> I tried 2 approaches in getting this done. But couldn't accomplish.
>
> Approach 1:
>
> <project name="Check Deletion task" basedir="." default="main">
>
>    <target name="main">
>        <delete>
>            <fileset dir="C:\Rootdir\Maindir\Parent" excludes="**\child 1\*,
> **\child 2\*, **\child5\*, **\child6\*"/>
>        </delete>
>    </target>
> </project>
>
> Result: This action deleted only the files under the child directories
>
> Approach 2:
>
> <project name="Check Deletion task" basedir="." default="main">
>
>    <target name="main">
>        <delete>
>            <fileset dir="C:\Rootdir\Maindir\Parent\child 1"/>
>            <fileset dir="C:\Rootdir\Maindir\Parent\child 2"/>
>            <fileset dir="C:\Rootdir\Maindir\Parent\child5"/>
>            <fileset dir="C:\Rootdir\Maindir\Parent\child6"/>
>        </delete>
>    </target>
> </project>
>
> Result: Same as approach 1 deleted all the files under respective child
> directories.
>
> Can anybody suggest me how to delete only 4 child directories and their
> files?
>
> Thanks A Ton
> Rohit
>

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