The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

App::DuplicateFilesUtils - CLI utilities related to duplicate files

VERSION

This document describes version 0.004 of App::DuplicateFilesUtils (from Perl distribution App-DuplicateFilesUtils), released on 2020-06-01.

DESCRIPTION

This distributions provides the following command-line utilities:

FUNCTIONS

move_duplicate_files_to

Usage:

 move_duplicate_files_to(%args) -> [status, msg, payload, meta]

Move duplicate files (except one copy) to a directory.

This utility will find all duplicate sets of files and move all of the duplicates (except one) for each set to a directory of your choosing.

See also: show-duplicate-files which lets you manually select which copies of the duplicate sets you want to move/delete.

This function is not exported.

This function supports dry-run operation.

Arguments ('*' denotes required arguments):

  • dir* => dirname

    Directory to move duplicate files into.

Special arguments:

  • -dry_run => bool

    Pass -dry_run=>1 to enable simulation mode.

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (payload) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

show_duplicate_files

Usage:

 show_duplicate_files() -> [status, msg, payload, meta]

Show duplicate files.

This is actually a shortcut for:

 % uniq-files -a --show-count --show-size --group-by-digest -R .

Sample output:

 % show-duplicate-files
 +------------------------------+---------+-------+
 | file                         | size    | count |
 +------------------------------+---------+-------+
 | ./tmp/P_20161001_112707.jpg  | 1430261 | 2     |
 | ./tmp2/P_20161001_112707.jpg | 1430261 | 2     |
 |                              |         |       |
 | ./20160420/IMG_3430-(95).JPG | 1633463 | 2     |
 | ./tmp/IMG_3430-(95).JPG      | 1633463 | 2     |
 |                              |         |       |
 | ./tmp/P_20161009_081735.jpg  | 1722586 | 2     |
 | ./tmp2/P_20161009_081735.jpg | 1722586 | 2     |
 |                              |         |       |
 | ./20160420/IMG_3430-(98).JPG | 1847543 | 3     |
 | ./tmp/IMG_3430-(98).JPG      | 1847543 | 3     |
 | ./tmp2/IMG_3430-(98).JPG     | 1847543 | 3     |
 |                              |         |       |
 | ./20160420/IMG_3430-(97).JPG | 1878472 | 2     |
 | ./tmp/IMG_3430-(97).JPG      | 1878472 | 2     |
 |                              |         |       |
 | ./20160420/IMG_3430-(99).JPG | 1960652 | 3     |
 | ./tmp/IMG_3430-(99).JPG      | 1960652 | 3     |
 | ./tmp2/IMG_3430-(99).JPG     | 1960652 | 3     |
 |                              |         |       |
 | ./20160420/IMG_3430-(96).JPG | 2042952 | 2     |
 | ./tmp/IMG_3430-(96).JPG      | 2042952 | 2     |
 |                              |         |       |
 | ./20160420/IMG_3430-(92).JPG | 2049127 | 2     |
 | ./tmp/IMG_3430-(92).JPG      | 2049127 | 2     |
 |                              |         |       |
 | ./20160420/IMG_3430-(94).JPG | 2109852 | 2     |
 | ./tmp/IMG_3430-(94).JPG      | 2109852 | 2     |
 |                              |         |       |
 | ./20160420/IMG_3430-(91).JPG | 2138724 | 2     |
 | ./tmp/IMG_3430-(91).JPG      | 2138724 | 2     |
 |                              |         |       |
 | ./20160420/IMG_3430-(93).JPG | 2190379 | 2     |
 | ./tmp/IMG_3430-(93).JPG      | 2190379 | 2     |
 +------------------------------+---------+-------+

You can then delete or move the duplicates manually, if you want. But there's also move-duplicate-files-to to automatically move all the duplicates (but one, for each set) to a directory of your choice.

To perform other actions on the duplicate copies, for example delete them, you can use uniq-files directly e.g. (in bash):

 % uniq-files -R -D * | while read f; do rm "$p"; done

This function is not exported.

No arguments.

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (payload) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

Return value: (any)

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/App-DuplicateFilesUtils.

SOURCE

Source repository is at https://github.com/perlancar/perl-App-DuplicateFilesUtils.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-DuplicateFilesUtils

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

SEE ALSO

uniq-files from App::UniqFiles

find-duplicate-filenames from App::FindUtils

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2020 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.