GithubHelp home page GithubHelp logo

mikijov / photo-cleanup Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 8.06 MB

photo-cleanup is a photo organizer, moving photos into organized directory structure.

License: Apache License 2.0

Go 100.00%

photo-cleanup's Introduction

photo-cleanup

License Build ReportCard

photo-cleanup is a photo organizer.

organize

$ photo-cleanup help organize
Moves photos from source into proper destination subdirectory.

Usage:
  photo-cleanup organize srcdir destdir [flags]

Flags:
      --all-files                   Process all files. Default is only images (jpg).
      --dir-fmt string              Directory format (default "yyyy/mm")
  -h, --help                        help for organize
      --hidden-files                Process hidden files. Default is only normal files.
      --min-size int                Minimum file size to consider for processing.
      --rename-duplicates           Rename duplicates by appending -1, -2 etc.
      --use-exif-time               Use time from exif meta data. (default true)
      --use-file-time               Use file modification time when no meta data.
      --use-filename-encoded-time   Attempt to parse time from filename. (default true)

Global Flags:
  -n, --dry-run                    Do not make any changes to files, only show what would happen.
      --ignore-permission-denied   Do not abort when encountering permission denied folders or files.
  -q, --quiet                      display no information while processing
  -v, --verbose                    display more information while processing

To move all images from source to target directory while at the same time organizing them into /dest///filename.ext structure, simply execute:

$ photo-cleanup organize /media/SDCARD /home/me/Photos

photo-cleanup is configured with common defaults, to ignore all hidden and non-image files. However, it supports multiple options to change destination directory structure, allow hidden and non-image files and many others.

General algorithm is as follows:

  • find all jpg, jpeg and mp4 files
  • determine creation time:
    • if file has embedded exif metadata use it (exif2 library currently supports only jpeg files)
    • if no exif data, see if the filename is in the IMG_yyyymmdd_HHMMSS.jpg or VID_yyyymmdd_HHMMSS.mp4 format and if so, extract the date.
    • if still no date and if --use-file-time is set, use file modification time
  • create new filepath using yyyy/mm or format specified using --dir-fmt
  • move all prepared files into new destination, skipping any files that already exist

dedupe

$ photo-cleanup help dedupe
Find and delete duplicate files.

Usage:
  photo-cleanup dedupe path [path...] [flags]

Flags:
      --chunk-size int              preferred chunk size when comparing files (default 65536)
      --empty-files-are-identical   treat empty files as identical duplicates
  -h, --help                        help for dedupe

Global Flags:
  -n, --dry-run                    Do not make any changes to files, only show what would happen.
      --ignore-permission-denied   Do not abort when encountering permission denied folders or files.
  -q, --quiet                      display no information while processing
  -v, --verbose                    display more information while processing

To delete all duplicate files from couple of paths simply execute:

$ photo-cleanup dedupe /media/Photos /media/Videos

photo-cleanup compares actual contents of the files rather then checksums. It attempts to minimize the amount of data it needs to read by skipping any files that are proven to be unique.

General algorithm is as follows:

  • find all files
  • group them according to size, i.e. different size => contents must be different
  • for each group of files
    • read chunk-size bytes
    • compare only to file that was equal up to that point
    • repeat until whole file read or all files proven different
    • if whole file read, delete all files that are duplicates

Features and ToDo

  • extract date/time from jpegs files
  • allow to customize destination directory format
  • organize duplicate filenames by appending -1, -2 etc.
  • detect binary identical files
  • extract date/time from mp4 files
  • support other file formats
  • organize using hard links instead of moving files

No Warranty

Please note that photo-cleanup comes with no warranty. I use it to manage my photos, but I am sure that some bugs have sneaked through. Backup your photos before letting photo-cleanup lose. See license for details.

Thanks

Thanks to Bobi Jones whose jpeg is used as test data.

photo-cleanup's People

Contributors

mikijov avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.