*** True. I took it to mean the differences of the contents of
like-named files.
*** Oh, so I did. Thanks for picking me up on that.
Richard Bonnerhttp://
www.chebucto.ca/~ak621/DOS/
I required in the second batch to compare name of files not contents
of file . When I tried FC command it compared contents like this :
F:\etisalat\batches>for %f in (F:\etisalat\batches\data\*.*) do fc %f
F:\etisalat\batches\new\*.*
F:\etisalat\batches>fc F:\etisalat\batches\data\1.txt F:\etisalat
\batches\new\*.
*
Comparing files F:\ETISALAT\BATCHES\DATA\1.txt and F:\ETISALAT\BATCHES
\NEW\1.txt
FC: no differences encountered
F:\etisalat\batches>fc F:\etisalat\batches\data\2.txt F:\etisalat
\batches\new\*.
*
Comparing files F:\ETISALAT\BATCHES\DATA\2.txt and F:\ETISALAT\BATCHES
\NEW\2.txt
FC: no differences encountered
F:\etisalat\batches>fc F:\etisalat\batches\data\3.txt F:\etisalat
\batches\new\*.
*
Comparing files F:\ETISALAT\BATCHES\DATA\3.txt and F:\ETISALAT\BATCHES
\NEW\3.txt
FC: no differences encountered
F:\etisalat\batches>fc F:\etisalat\batches\data\4.txt F:\etisalat
\batches\new\*.
*
Comparing files F:\ETISALAT\BATCHES\DATA\4.txt and F:\ETISALAT\BATCHES
\NEW\4.txt
FC: no differences encountered
But when I tried that batch below I got wrong results (wrong file
names not even exist in the folders mentioned in set statements
:
@echo off
set fldr1="F:\etisalat\batches\data"
set fldr2="F:\etisalat\batches\new"
for %%A in (%fldr1%\*.*) do (
if not exist %fldr2%\%%~nxA (
echo %%~nxA in %fldr1% and NOT in %fldr2%)
)
)
for %%A in (%fldr2%\*.*) do (
if not exist %fldr1%\%%~nxA (
echo %%~nxA in %fldr2% and NOT in %fldr1%)
)
)
Results:
:----------
data in "F:\etisalat\batches\data" and NOT in "F:\etisalat\batches
\new"
GOM PLAYEREN SETUP.EXE in "F:\etisalat\batches\data" and NOT in "F:
\etisalat\batches\new"
realalt182.exe in "F:\etisalat\batches\data" and NOT in "F:\etisalat
\batches\new"
new in "F:\etisalat\batches\new" and NOT in "F:\etisalat\batches
\data"
GOM PLAYEREN SETUP.EXE in "F:\etisalat\batches\new" and NOT in "F:
\etisalat\batches\data"
realalt182.exe in "F:\etisalat\batches\new" and NOT in "F:\etisalat
\batches\data"