Organize photos using EXIF info from exiftool
NOTE: currently the files are not copied; a filename is created with touch to simulate what would happen for testing.
It hurts so good. Also, it's built into many Linux distros. Honestly, I don't really know.
- photo_org.sh
Currently I'm running it with this:
find pics \( -iname "*.jpg" -o -iname "*.heic" -o -iname "*.png" -o -iname "*.jpeg" \) -exec ./photo_org.sh pics3 "{}" \; | tee log2
- everything else
Copy all photo files from one unorganized directory tree of files into an organized tree of files with standard names using EXIF info.
Files are organized by year and month according to the EXIF information in this order:
CreateDate
ModifyDate
DateCreated
FileModifyDate
- or the file is not copied
Files are named D_M_N_Q_S.ext where
- D = yyyy_mm_dd_hh_MM_ss_
- M = model
- N = EXIF
FileNumber
- Q = EXIF
SequenceNumber
- ext = original file extension
Model comes from:
- "thumbnail" if the filename contains "thumbnail"
- "preview" if the filename contains "preview"
- first word of EXIF
Software
, e.g. Picasa - first 2 words of
LensModel
, e.g. iPhone 5s - filename keywords:
- webcam -> webcam
- iphone -> iPhone
- scan -> scanned
- z2 -> dImage_Z2
- argus -> argus
- /micro/ -> USB_microscope
- smugmug -> smugmug
- screen shot -> screenshot
- "webcam" if the EXIF
Comment
contains "webcam"
- wrap params to functions in double quotes
- or capture all possible params in the function with
$@
/$*
- or capture all possible params in the function with
- lowercase vars with
${var,,}
- uppercase vars with
${var^^}
- turn params into var references
declare -n var=$1
- pipes are run in subshells, so piping to readarray assigns to a var in a subshell
- replace var chars with
${var/x/y}
- get substrings or array slices with
${var:x}
or${var:x:y}
- can use a var for
x
ory
, e.g.${var:${var2}:${var3}}
- can use a var for
- match in
if [[ ... ]]
with=~
- note that quotes are not required
- use a var for wonky stuff