Giter Club home page Giter Club logo

adri's Introduction

adri Gem Version

adri organizes JPEG/TIFF photographs according to their EXIF date and location data into a custom directory structure.

In other words, it turns this:

$ tree photos/
photos/
├── IMG100001.jpg
├── IMG100002.jpg
└── IMG100003.jpg

To this:

$ tree photos/
photos/
└── 2018/
    └── 10/
        └── 14/
            └── London
                ├── IMG100001.jpg
                ├── IMG100002.jpg
                └── IMG100003.jpg

Installation

Install the necessary packages. For Debian/Ubuntu, issue:

sudo apt install ruby-full git build-essential libexif-dev

Install adri:

sudo gem install adri

Configuration

API key

The GPS coordinates (latitude, longitude) of each photograph's EXIF headers are converted to a corresponding location name using the Google Maps API. For this, you need a free API key with the Geocoding API enabled.

You can set the ADRI_GOOGLE_API_KEY environment variable in your shell's configuration file. For Bash, issue:

$ cat >>.~/.bashrc
export ADRI_GOOGLE_API_KEY=yourapikeyhere
^D

Note: ^D stands for Ctrl-D

You can also pass the API key as a command line option with --api-key. This overrides the environment variable.

Location language

It's possible to configure the language (default is en for English) used in location names by setting the ADRI_LOCALE environment variable in your shell's configuration file.

To set the language to Greek in Bash, issue:

$ cat >>.~/.bashrc
export ADRI_LOCALE=el
^D

Note: ^D stands for Ctrl-D

You can also pass the language as a command line option with --locale. This overrides the environment variable.

Use

To get the help text, issue:

$ adri -h
usage: adri [options] <path>...
    -p, --prefix       Place everything under this path (default: photo parent directory)
    -f, --path-format  Format path with strftime and %{location} (default: %Y/%m/%d/%{location})
    --api-key          Google Maps API key (default: $ADRI_GOOGLE_API_KEY)
    --locale           Locale to use for %{location} in path format (default: $ADRI_LOCALE or en)
    --run              Perform changes instead of a dry run
    -q, --quiet        Do not print operations
    --version          Print program version
    -h, --help         Print help text

Dry run mode (default)

By default, adri runs in dry run mode, printing (DRY RUN) at the end of each line. This means it simply prints out what it would do, without actually doing it:

$ pwd
/home/agorf/work/adri/
$ tree photos/
photos/
├── IMG100001.jpg
├── IMG100002.jpg
└── IMG100003.jpg
$ adri photos/*.jpg
/home/agorf/work/adri/photos/IMG100001.jpg -> /home/agorf/work/adri/photos/2018/10/14/London/IMG100001.jpg (DRY RUN)
/home/agorf/work/adri/photos/IMG100002.jpg -> /home/agorf/work/adri/photos/2018/10/14/London/IMG100002.jpg (DRY RUN)
/home/agorf/work/adri/photos/IMG100003.jpg -> /home/agorf/work/adri/photos/2018/10/14/London/IMG100003.jpg (DRY RUN)
$ tree photos/
photos/
├── IMG100001.jpg
├── IMG100002.jpg
└── IMG100003.jpg

Run mode

To apply the changes, use the --run option:

$ adri --run photos/*.jpg
/home/agorf/work/adri/photos/IMG100001.jpg -> /home/agorf/work/adri/photos/2018/10/14/London/IMG100001.jpg
/home/agorf/work/adri/photos/IMG100002.jpg -> /home/agorf/work/adri/photos/2018/10/14/London/IMG100002.jpg
/home/agorf/work/adri/photos/IMG100003.jpg -> /home/agorf/work/adri/photos/2018/10/14/London/IMG100003.jpg
$ tree photos/
photos/
└── 2018/
    └── 10/
        └── 14/
            └── London/
                ├── IMG100001.jpg
                ├── IMG100002.jpg
                └── IMG100003.jpg

Path prefix

To place everything under a path other than the parent directory of each photograph, use the --prefix option:

$ adri --prefix . photos/*.jpg
/home/agorf/work/adri/photos/IMG100001.jpg -> /home/agorf/work/adri/2018/10/14/London/IMG100001.jpg (DRY RUN)
/home/agorf/work/adri/photos/IMG100002.jpg -> /home/agorf/work/adri/2018/10/14/London/IMG100002.jpg (DRY RUN)
/home/agorf/work/adri/photos/IMG100003.jpg -> /home/agorf/work/adri/2018/10/14/London/IMG100003.jpg (DRY RUN)

Path format

The default path format is %Y/%m/%d/%{location} which stands for year/month/day/location. Everything other than %{location} is formatted according to strftime(3).

It is possible to specify a custom path with the --path-format option:

$ adri --path-format '%{location}/%b %Y/%d' photos/*.jpg
/home/agorf/work/adri/photos/IMG100001.jpg -> /home/agorf/work/adri/photos/London/Oct 2018/14/IMG100001.jpg (DRY RUN)
/home/agorf/work/adri/photos/IMG100002.jpg -> /home/agorf/work/adri/photos/London/Oct 2018/14/IMG100002.jpg (DRY RUN)
/home/agorf/work/adri/photos/IMG100003.jpg -> /home/agorf/work/adri/photos/London/Oct 2018/14/IMG100003.jpg (DRY RUN)

Processing many photos

It's also possible to process many photos at once by passing space-separated file names and directories (in which case adri will recurse):

$ adri photos/IMG100001.jpg photos/IMG100002.jpg photos/IMG100003.jpg
/home/agorf/work/adri/photos/IMG100001.jpg -> /home/agorf/work/adri/photos/2018/10/14/London/IMG100001.jpg (DRY RUN)
/home/agorf/work/adri/photos/IMG100002.jpg -> /home/agorf/work/adri/photos/2018/10/14/London/IMG100002.jpg (DRY RUN)
/home/agorf/work/adri/photos/IMG100003.jpg -> /home/agorf/work/adri/photos/2018/10/14/London/IMG100003.jpg (DRY RUN)
$ adri photos/
/home/agorf/work/adri/photos/IMG100001.jpg -> /home/agorf/work/adri/photos/2018/10/14/London/IMG100001.jpg (DRY RUN)
/home/agorf/work/adri/photos/IMG100002.jpg -> /home/agorf/work/adri/photos/2018/10/14/London/IMG100002.jpg (DRY RUN)
/home/agorf/work/adri/photos/IMG100003.jpg -> /home/agorf/work/adri/photos/2018/10/14/London/IMG100003.jpg (DRY RUN)

License

MIT

Author

Angelos Orfanakos

adri's People

Contributors

agorf avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.