You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Robert Pepersack <RP...@mdinsurance.state.md.us> on 2006/10/10 22:24:09 UTC
Check to See If Directory Exists
Hi all,
I need to check to see if a directory exists, and if not, then create
the directory. But, if the directory already exists, then leave it
alone, because it may already contain some important files. I have more
than a dozen directories to check for, and I would like to find a way to
do this that's less verbose than a bunch of <property> and <available>
tasks. Does anyone know how?
Here's the equivalent command from a batch file:
if not exist c:\myapp mkdir c:\myapp
Thanks,
Bob
Robert Pepersack
Senior Lead Developer
Maryland Insurance Administration
410-468-2054
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Check to See If Directory Exists
Posted by Peter Reilly <pe...@gmail.com>.
<mkdir dir="x"/> will create the directory x if it does not
exist, otherwise it does nothing.
Peter
On 10/10/06, Robert Pepersack <RP...@mdinsurance.state.md.us> wrote:
> Hi all,
>
> I need to check to see if a directory exists, and if not, then create
> the directory. But, if the directory already exists, then leave it
> alone, because it may already contain some important files. I have more
> than a dozen directories to check for, and I would like to find a way to
> do this that's less verbose than a bunch of <property> and <available>
> tasks. Does anyone know how?
>
> Here's the equivalent command from a batch file:
>
> if not exist c:\myapp mkdir c:\myapp
>
> Thanks,
>
> Bob
>
> Robert Pepersack
> Senior Lead Developer
> Maryland Insurance Administration
> 410-468-2054
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Check to See If Directory Exists
Posted by Dominique Devienne <dd...@gmail.com>.
> I need to check to see if a directory exists, and if not, then create
> the directory. But, if the directory already exists, then leave it
> alone, because it may already contain some important files. I have more
> than a dozen directories to check for, and I would like to find a way to
> do this that's less verbose than a bunch of <property> and <available>
> tasks. Does anyone know how?
>
> Here's the equivalent command from a batch file:
>
> if not exist c:\myapp mkdir c:\myapp
Well, since <mkdir> is a no-op for an existing directory, you don't
even need to use <available>. And to process several dirs, either
manually write all the <mkdir>s, or select the dirs in a <fileset> or
<path>, and loop over it using Ant-Contrib's <for> task. --DD
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org