Announcement

#16 2019-08-09 21:04:17

erAck
Only trying to help
2015-09-06
2031

Re: Duplicates

If you merely want to check for duplicates under the galleries folder and get a list of files (which you then can work with), save the following code as a duplicates.sh shell script and give it the execute bit and invoke it in your Piwigo folder (above the galleries folder). Ensure you keep and don't omit the two apostrophe / single quote characters that enclose the awk script when copy-pasting the code.

Code:

#!/bin/sh
find galleries -type f -print0 | xargs -0 md5sum | awk '
    {
        ++s[$1];
        f[$1][s[$1]] = $2
    }
    END {
        for (x in s) {
            if (s[x] > 1) {
                for (i in f[x])
                    print x, f[x][i]
            }
        }
    }
'

This script can be adjusted to also check files under the upload directory by simply adding that to the list of find directories, as in find galleries upload -type f ...

This needs gawk for true multidimensional arrays. If you happen to have only mawk or another inferior awk implementation you're out of luck and need to rewrite.


Running Piwigo at https://erack.net/gallery/

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact