You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by ritchie <ga...@baml.com> on 2011/02/25 16:32:19 UTC
compare files from 2 directories
I want to check files from 2 directories for filematch, I tried using
checksum task but it does not work for 2 directories. Is it possible to
attain this by using ant alone?
--
View this message in context: http://ant.1045680.n5.nabble.com/compare-files-from-2-directories-tp3400285p3400285.html
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: compare files from 2 directories
Posted by ritchie <ga...@baml.com>.
I did something like this...
<target name="a">
<checksum totalproperty="ab1">
<fileset dir="C:\A workspace\B"/>
</checksum>
<delete>
<fileset dir="C:\A workspace\B" includes="**/*.MD5"/>
</delete>
<checksum totalproperty="ab2">
<fileset dir="C:\A workspace\A"/>
</checksum>
<delete>
<fileset dir="C:\A workspace\A" includes="**/*.MD5"/>
</delete>
<condition property="checksuccess">
<equals arg1="${ab1}" arg2="${ab2}" />
</condition>
</target>
<target name="b" depends="a" if="checksuccess">
<echo message="ab1 and ab2 are same"/>
</target>
--
View this message in context: http://ant.1045680.n5.nabble.com/compare-files-from-2-directories-tp3400285p3403355.html
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: compare files from 2 directories
Posted by Antoine Levy-Lambert <an...@gmx.de>.
If you want to compare two directories using ant, you can do this by
using the present and the different selectors.
<!-- 1 - find files which are in directory bar but not in foo see [1] -->
<fileset dir="bar" id="onlyinbar">
<not>
<present present="srconly" targetdir="foo"/>
</not>
</fileset>
<echo>these files are only in bar : ${toString:onlyinbar}</echo>
<!-- 2 - find files which exist in both bar and foo but are different -->
<fileset dir="foo" id="differentbarfoo">
<different targetdir="bar"
ignoreFileTimes="true"/>
</fileset>
<echo>these files are different in bar compared to foo :
${toString:differentbarfoo}</echo>
Regards,
Antoine
[1] http://ant.apache.org/manual/Types/selectors.html#presentselect
[2] http://ant.apache.org/manual/Types/selectors.html#differentselect
On 2/25/2011 10:32 AM, ritchie wrote:
> I want to check files from 2 directories for filematch, I tried using
> checksum task but it does not work for 2 directories. Is it possible to
> attain this by using ant alone?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: compare files from 2 directories
Posted by ritchie <ga...@baml.com>.
The problem was it was inserting the .md5 file in the same directory and also
the name of the file was different, now it works.
I have another problem though i have to compare 2 directories for files and
if file name matches then do a checksum or filesmatch, i could not find a
ant task which can do this. I have written a java class to do this but i
wanted to know whether this can be achieved without invoking a java or perl.
--
View this message in context: http://ant.1045680.n5.nabble.com/compare-files-from-2-directories-tp3400285p3412581.html
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: compare files from 2 directories
Posted by Antoine Levy-Lambert <an...@gmx.de>.
Maybe you have a program running which is writing a log file under
C:\Program Files.
You should try on a tiny set of files which you know are not going to
change.
Regards,
Antoine
On 2/25/2011 11:32 AM, ritchie wrote:
> I used the below checksum task and i passed the same directory twice but i am
> getting different values for the same directory.
>
> <target name="a">
>
> <checksum totalproperty="ab1">
> <fileset dir="C:\program files"/>
>
>
> </checksum>
> <checksum totalproperty="ab2">
> <fileset dir="C:\program files"/>
> </checksum>
> <echo>value of prop is ${ab1}</echo>
> <echo>${ab2}</echo>
>
> </target>
>
>
>
> [echo] value of prop is 8a76f4364f3d593d9af177630b22b431
> [echo] fb3eb4fb22641ba916e55230b597b12a
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: compare files from 2 directories
Posted by ritchie <ga...@baml.com>.
I used the below checksum task and i passed the same directory twice but i am
getting different values for the same directory.
<target name="a">
<checksum totalproperty="ab1">
<fileset dir="C:\program files"/>
</checksum>
<checksum totalproperty="ab2">
<fileset dir="C:\program files"/>
</checksum>
<echo>value of prop is ${ab1}</echo>
<echo>${ab2}</echo>
</target>
[echo] value of prop is 8a76f4364f3d593d9af177630b22b431
[echo] fb3eb4fb22641ba916e55230b597b12a
--
View this message in context: http://ant.1045680.n5.nabble.com/compare-files-from-2-directories-tp3400285p3400389.html
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