Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Finding old copies of files

by Leitz (Scribe)
on Feb 27, 2021 at 14:44 UTC ( #11128878=note: print w/replies, xml ) Need Help??


in reply to Re: Finding old copies of files
in thread Finding old copies of files

Same name and size, in:

$known_files{$file}{$size} = 1;

An MD5 or SHA-256 sum would catch different files of the same size. However, they are computationally intense and in this use case overkill. I'm making one authoritative version and then revising after things are cleaned up. Thus any changed files are likely to get changed a few more times.

Chronicler: The Domici War (domiciwar.net)

General Ne'er-do-well (github.com/LeamHall)

Replies are listed 'Best First'.
Re^3: Finding old copies of files
by afoken (Chancellor) on Feb 27, 2021 at 15:29 UTC
    An MD5 or SHA-256 sum would catch different files of the same size. However, they are computationally intense and in this use case overkill

    Calculating the MD5 of a file should not be significantly slower than copying the file on a modern computer.

    You could even optimize by delaying the MD5 calculation until you find a second file with same size and base name.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^3: Finding old copies of files
by afoken (Chancellor) on Feb 28, 2021 at 09:49 UTC
    $known_files{$file}{$size} = 1;

    Change that to ...

    $known_files{$file}{$size}++;

    ... and you know how many (possible) duplicates you have found.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^3: Finding old copies of files
by parv (Vicar) on Feb 27, 2021 at 20:32 UTC

    Ah, right; I had missed that. Appreciate the correction.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11128878]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2023-02-03 16:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (27 votes). Check out past polls.

    Notices?