Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Compare old and new folder trees, delete if old\fldr1\a.a = new\fldr1\a.a

Apr
1,794
15
Since this seems like it might be widely used, didn't know if someone had this routine or a EXE already?

Basically I need to compare two folder trees, and if old\fldr1\a.a has the same contents as new\fldr1\a.a, then delete old\fldr1\a.a

TIA
 
Thank you @Charles Dye .

Code:
[C:\Windows\system32]dedupe /S /D /V /SHA512 "C:\Z_YahooGoogleData\Facebook New" "C:\Z_YahooGoogleData\Facebook Old"
C:\Z_YahooGoogleData\Facebook Old\"C:\Z_YahooGoogleData\Facebook New"
Total files: 0  Unique: 0  Duplicates: 0

Does not seem right. No files were processed.....
 
Code:
dedupe /S /D /V /SHA512 * "C:\Z_YahooGoogleData\Facebook New" "C:\Z_YahooGoogleData\Facebook Old"

The filename is not optional.
 
Thank you again @Charles Dye . Is there any possibility that one of the @SHA### routines might not give accurate results like @compare would, since it's byte by byte?

I was thinking something like the following

Code:
text
  C:\> [0] dir1 dir2

    if not %@right[1,%dir1] == "\" set dir1=%dir1%\
    if not %@right[1,%dir2] == "\" set dir2=%dir2%\

    for /r %fn1 in (dir1\*) (
        echos Processing [%fn1]...
        set fn2=%@replace[%dir1,%dir2,%fn1]
        if isfile "%fn2"
            :: %%@compare[] == 1 then same, else different
          if %@compare["%fn1","%fn2"] eq 1
                echo (same)
                del /q "%fn2"
            else
                echo (diff)
            endiff
        else
            echo (n/e)
        endiff
    )
endtext
 
looks like dedupe compares all files in a tree - not just in the same subtree and same name. Not what I wanted to do. And dedupe does not have a /N not really switch.
 
Back
Top