Pixif can copy or move photos from a source directory to a destination directory using EXIF data to build the resulting file path.
For example, photos saved in Dropbox/Camera Uploads/
can automatically be moved to Pictures/2012/2012-01-02/20120102-IMG001.jpg
which would be based on the date the photo was taken.
Pixif was mainly developed to easily transfer photos uploaded via Dropbox's Camera Upload
feature to a main photo storage folder located elsewhere.
Derrick Gilland
- Python 2.6+
Special thanks to ianare for developing EXIF, the EXIF python module used in this project.
See LICENSE file.
Pixif can be run from the command-line using 2 methods:
- Command-line options
- Configuration file
Full invocation using short options:
$ python pixif.py -s /path/to/source -d /path/to/destination -a {EXIF}/{Tag}/{Save}-{Structure} -m method -l -o
Full invocation using long options:
$ python pixif.py --src /path/to/source --dst /path/to/destination --saveas {EXIF}/{Tag}/{Save}-{Structure} --method method --log --overwrite
String. Source file path.
String. Destination file path.
String. Format string syntax with EXIF tag names delimited by braces {}
, e.g., {Year}/{Year}-{Month}-{Day}/{Name}
.
See EXIF.py's EXIF_TAGS constant for full list.
String. Acceptable values: copy
or move
.
Boolean. Enable logging.
Boolean. Overwrite existing photos when transferred.
See sample-config.ini.
; section titles names are arbitrary but will be used as id for log entries
[alpha]
; src: source folder location
src=test/in
; dst: destination folder location
dst=test/out
; saveas: format for saving file
saveas={Year}/{Year}-{Month}-{Day}/{Name}
; given the above with
; src photo: test/in/IMG_001.jpg taken 2012/01/02
; resultant save file will be:
; dst photo: test/out/2012/2012-01-02/IMG_001.jpg
; method: copy or move files
method=copy
; log: true/false indicates whether to log to pixif.log in same folder as this config
log=true
; overwrite: true/false indicates whether to overwrite existing files in destination
overwrite=true
; enabled: true/false enables/disables this section
enabled=true
Below is an example setup for using Cron to schedule periodic photo transfers.
/Users/username/Dropbox/Camera Uploads/pixif.ini contents:
[dropbox-uploads]
src=/Users/username/Dropbox/Camera Uploads/
dst=/Users/username/Pictures/
saveas={Year}/{Year}-{Month}-{Day}/{Name}
method=move
log=true
overwrite=false
enabled=true
-
Edit Cron:
$ crontab -e
-
Set process schedule for every 60 minutes:
*/60 * * * * python /Users/username/projects/pixif/pixif.py /Users/username/Dropbox/Camera\ Uploads/pixif.ini
-
Save Cron.
After this process runs for the first time, /Users/username/Dropbox/Camera Uploads/pixif.log
will contain a log of all pictures transferred using pixif.
Replace /Users/username/Dropbox/Camera\ Uploads/pixif.ini
in step 2
above with:
-src /Users/username/Dropbox/Camera\ Uploads/ -dst /Users/username/Pictures/ -a {Year}/{Year}-{Month}-{Day}/{Name} -m move -l
So that the full crontab entry is:
*/60 * * * * python /Users/username/projects/pixif/pixif.py -src /Users/username/Dropbox/Camera\ Uploads/ -dst /Users/username/Pictures/ -a {Year}/{Year}-{Month}-{Day}/{Name} -m move -l