You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Aaron Mackley <Aa...@dtint.com> on 2010/09/09 23:40:03 UTC

Trouble with and

I have a single file that needs to be copied into a random folder name.
I know the folder path except for the last folder, which will be called
xxxxxxxx.default, where xxxxxxxx is a random set of characters. 

 

This may be easier than I am trying to make it, but I am trying to use a
DirSet within a Copy, like this:

 

                                <property name="firefox.dir"
value="${env.APPDATA}/Mozilla/FireFox/Profiles"/>

                                

                                <copy todir="${firefox.dir}">

                                                <dirset
dir="${firefox.dir}">

                                                                <include
name="**/*.default"/>

                                                </dirset>

                                                <fileset
dir="${apps.dir}/Firefox">

                                                                <include
name="prefs.js"/>

                                                </fileset>

                                </copy>

 

 

I also tried a simple method like this:

                                <copy
file="${apps.dir}/Firefox/prefs.js"
todir="${env.APPDATA}/Mozilla/FireFox/Profiles/**.default"/>

 

But that didn't work either. I just got a copy error. 

 

 

Is there an easier way to simply copy one file to a random folder or
even a set of folders with a DirSet?

 

 

 

Aaron Mackley   |  QA Engineering  |  Digital Technology International
| 801-853-5000  |  aaron.mackley@dtint.com
<ma...@dtint.com> 

Transform profitably with our new Targeted Audience Solutions and DTI
Cloud. Get started at www.dtint.com
<file:///C:\Documents%20and%20Settings\amackley\Application%20Data\Micro
soft\Signatures\www.dtint.com> .


Re: Trouble with and

Posted by Michael Ludwig <mi...@gmx.de>.
Aaron Mackley schrieb am 10.09.2010 um 13:06 (-0500):
> With a few adjustments, I got it to work correctly. The following code
> copied the one file (prefs.js) to the randomly generated folder
> location: (I've added some comments for anyone who follows this thread
> later.)

Cool. I copied this, and produced another (otherwise pointless) sample
for illustrative and archival purposes.

<project>
  <property environment="env"/>
  <property name="firefox.dir"
    value="${env.APPDATA}/Mozilla/FireFox/Profiles"/>

  <!-- Random dir where firefox puts the user profile. -->
  <path id="path.firefox.default.profile">
    <dirset dir="${firefox.dir}">
      <include name="**/*.default" />
    </dirset>
  </path>

  <!-- This is the trick to get the string
       value of the @id into a property.   -->

  <property name="firefox.default.profile.dir"
    location="${toString:path.firefox.default.profile}" />

  <echo>${firefox.default.profile.dir}</echo>
</project>

-- 
Michael Ludwig

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


RE: Trouble with and

Posted by Aaron Mackley <Aa...@dtint.com>.
Thanks Darragh. I learned three separate principles in getting this to
work with yours and Stefan's help.

With a few adjustments, I got it to work correctly. The following code
copied the one file (prefs.js) to the randomly generated folder
location: (I've added some comments for anyone who follows this thread
later.)

<property name="firefox.dir"
value="${env.APPDATA}/Mozilla/FireFox/Profiles"/>

<path id="path.firefox.default.profile"> <!--Where firefox puts the
profiles. I had not been using the path task. -->
	<dirset dir="${firefox.dir}">
		<include name="**/*.default" />
	</dirset>
</path>

<!-- This line was the all important missing get the location (path id)
into an actual property. I had not done that. -->
<property name="firefox.default.profile.dir"
location="${toString:path.firefox.default.profile}" />

<!--The rest is pretty straight forward -->	
<copy todir="${firefox.default.profile.dir}" >
  <fileset dir="${apps.dir}/Firefox" >
	<include name="prefs.js" />
  </fileset>
</copy>

Aaron Mackley   |  QA Engineering  |  Digital Technology International
| 801-853-5000  |  aaron.mackley@dtint.com
Transform profitably with our new Targeted Audience Solutions and DTI
Cloud. Get started at www.dtint.com.

-----Original Message-----
From: Bailey, Darragh [mailto:dbailey@hp.com] 
Sent: Friday, September 10, 2010 10:04 AM
To: Ant Users List
Subject: RE: Trouble with <copy> and <DirSet>


> -----Original Message-----
> From: Aaron Mackley [mailto:Aaron.Mackley@dtint.com] 
> Sent: 10 September 2010 15:40
> To: user@ant.apache.org
> Subject: RE: Trouble with <copy> and <DirSet>
> 
> Stefan,

<snip>

> I currently have this code: (I am trying to copy prefs.js to 
> the random
> directory *.default.)
> 
> <copy todir="${firefox.dir}">
> 	<dirset dir="${firefox.dir}">
> 		<include name="**/*.default"/>
> 	</dirset>
> 	<fileset dir="${apps.dir}/Firefox">
> 		<include name="prefs.js"/>
> 	</fileset>
> </copy>
> 
> 
> 
> Is this the right way to go about this?

That would attempt to copy the xxxxxxxxx.default directory to the
firefox directory.

There was a thread a week ago titled "How to get the last folder name?"
which should solve this problem for you.

> I want to get the path to the last child folder in some parent 
> directory. Tried this:
> 
>          <path id="_lastname">
>              <last>
>                  <sort>
>                      <fileset dir="C:\my\parent"/>
>                  </sort>
>              </last>
>          </path>
>          <property name="_lastname2" location="${_lastname}"/>


The person had one mistake that was corrected by Matt Benson, he should
have used "${toString:_lastname}" in order to convert to a property.

So your code would become something like the following:

<path id="path.firefox.default.profile">
  <dirset dir="${firefox.dir}">
    <!-- 
       I'm assumming that to avoid getting a directory below 
       the profile directory, that sort will return the results 
       in the order of the shortest path.
    -->
    <first>
      <sort>
        <include name="**/*.default" />
      </sort>
    </first>
  </dirset>
</path>

<property name="firefox.default.profile.dir"
location="${toString:path.firefox.default.profile}" />

<copy todir="${firefox.default.profile.dir}" >
  <fileset dir="${apps.dir}/Firefox" >
    <include name="prefs.js" />
  </fileset>
</copy>


This is untested and just constructed based on the person saying that it
worked after making the changes suggested.


--
Regards,
Darragh Bailey

---------------------------------------------------------------------
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: Trouble with and

Posted by "Bailey, Darragh" <db...@hp.com>.
> -----Original Message-----
> From: Aaron Mackley [mailto:Aaron.Mackley@dtint.com] 
> Sent: 10 September 2010 15:40
> To: user@ant.apache.org
> Subject: RE: Trouble with <copy> and <DirSet>
> 
> Stefan,

<snip>

> I currently have this code: (I am trying to copy prefs.js to 
> the random
> directory *.default.)
> 
> <copy todir="${firefox.dir}">
> 	<dirset dir="${firefox.dir}">
> 		<include name="**/*.default"/>
> 	</dirset>
> 	<fileset dir="${apps.dir}/Firefox">
> 		<include name="prefs.js"/>
> 	</fileset>
> </copy>
> 
> 
> 
> Is this the right way to go about this?

That would attempt to copy the xxxxxxxxx.default directory to the firefox directory.

There was a thread a week ago titled "How to get the last folder name?" which should solve this problem for you.

> I want to get the path to the last child folder in some parent 
> directory. Tried this:
> 
>          <path id="_lastname">
>              <last>
>                  <sort>
>                      <fileset dir="C:\my\parent"/>
>                  </sort>
>              </last>
>          </path>
>          <property name="_lastname2" location="${_lastname}"/>


The person had one mistake that was corrected by Matt Benson, he should have used "${toString:_lastname}" in order to convert to a property.

So your code would become something like the following:

<path id="path.firefox.default.profile">
  <dirset dir="${firefox.dir}">
    <!-- 
       I'm assumming that to avoid getting a directory below 
       the profile directory, that sort will return the results 
       in the order of the shortest path.
    -->
    <first>
      <sort>
        <include name="**/*.default" />
      </sort>
    </first>
  </dirset>
</path>

<property name="firefox.default.profile.dir" location="${toString:path.firefox.default.profile}" />

<copy todir="${firefox.default.profile.dir}" >
  <fileset dir="${apps.dir}/Firefox" >
    <include name="prefs.js" />
  </fileset>
</copy>


This is untested and just constructed based on the person saying that it worked after making the changes suggested.


--
Regards,
Darragh Bailey

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


RE: Trouble with and

Posted by Aaron Mackley <Aa...@dtint.com>.
Stefan,

Thank you for your response on this. You stated:

" This would match any directory that end in .default - but not the
files
contained within them."

I actually need to pick up the name of the directory, not the files, but
your information was helpful.

My specific task is that I need to copy one file to a randomly generated
directory. The installation process creates a randomly generated
directory name. I have to identify that randomly generated name and then
copy the one file to that directory.

I currently have this code: (I am trying to copy prefs.js to the random
directory *.default.)

<copy todir="${firefox.dir}">
	<dirset dir="${firefox.dir}">
		<include name="**/*.default"/>
	</dirset>
	<fileset dir="${apps.dir}/Firefox">
		<include name="prefs.js"/>
	</fileset>
</copy>



Is this the right way to go about this?


Aaron Mackley   |  QA Engineering  |  Digital Technology International
| 801-853-5000  |  aaron.mackley@dtint.com
Transform profitably with our new Targeted Audience Solutions and DTI
Cloud. Get started at www.dtint.com.
-----Original Message-----
From: Stefan Bodewig [mailto:bodewig@apache.org] 
Sent: Thursday, September 09, 2010 10:14 PM
To: user@ant.apache.org
Subject: Re: Trouble with <copy> and <DirSet>

On 2010-09-09, Aaron Mackley wrote:

> I have a single file that needs to be copied into a random folder
> name.  I know the folder path except for the last folder, which will
> be called xxxxxxxx.default, where xxxxxxxx is a random set of
> characters.
> 
> This may be easier than I am trying to make it, but I am trying to use
> a DirSet within a Copy, like this:

> <dirset dir="${firefox.dir}">
>   <include name="**/*.default"/>
> </dirset>

This would match any directory that end in .default - but not the files
contained within them.

<fileset dir="${firefox.dir}">
   <include name="**/*.default/**"/>
</fileset>

is probably what you want.

Stefan

---------------------------------------------------------------------
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: Trouble with and

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-09-09, Aaron Mackley wrote:

> I have a single file that needs to be copied into a random folder
> name.  I know the folder path except for the last folder, which will
> be called xxxxxxxx.default, where xxxxxxxx is a random set of
> characters.
> 
> This may be easier than I am trying to make it, but I am trying to use
> a DirSet within a Copy, like this:

> <dirset dir="${firefox.dir}">
>   <include name="**/*.default"/>
> </dirset>

This would match any directory that end in .default - but not the files
contained within them.

<fileset dir="${firefox.dir}">
   <include name="**/*.default/**"/>
</fileset>

is probably what you want.

Stefan

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