Skip to content

Instantly share code, notes, and snippets.

@paolobenve
Last active May 16, 2018 09:25
Show Gist options
  • Save paolobenve/72525d69c1c069e4cc5748a918057a7c to your computer and use it in GitHub Desktop.
Save paolobenve/72525d69c1c069e4cc5748a918057a7c to your computer and use it in GitHub Desktop.
a simple script that reads exif date from arw files and renames them and the corresponding xmp using the given name and the date
#!/bin/bash
# first argument: the main part of the new name
# following arguments: the *.ARW files you want to rename
#
# example:
# $ rename-ARW-and-xmp-with-date "new name" DSC02*.ARW
name=$1
shift
for i
do
file="$i"
date=$(exiv2 -g Exif.Photo.DateTimeOriginal pr "$file" | cut -c61-79)
date=${date:0:4}-${date:5:2}-${date:8:2}--${date:11:2}.${date:14:2}.${date:17:2}
echo mv "$file" "$name $date".ARW
mv "$file" "$name $date".ARW
echo mv "$file".xmp "$name $date".ARW.xmp
mv "$file".xmp "$name $date".ARW.xmp
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment