Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I recently gave ~200 photos numerical titles in Shotwell which describe their sequences--001, 002, etc. But I'd like for this sequence to be the same in the filenames, too, so that when I open the folder in Nautilus the photos are listed in order. I think Shotwell saved the title in the exif data somewhere. In fact, I finally found it using the Gnome image viewer, under XMP Other and photoshop:Headline. What I'd like is a way to read these Shotwell titles and have those used as the filenames. I could probably do this with Python if I knew how to access that metadata.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

I did a $ apt-cache search exif, and found (among other packages):

exiv2 - EXIF/IPTC metadata manipulation tool  
bins - Generate static HTML photo albums using XML and EXIF tags  
exif - command-line utility to show EXIF information in JPEG files  
exifprobe - Read metadata from digital pictures  
exiftags - utility to read Exif tags from a digital camera JPEG file  
jigl - Generates a static html photo gallery from one or more directories of images  
libexif-ruby1.9.1 - EXIF tag parsing Library for ruby1.9.1  
libimage-exif-perl - Perl module to extract EXIF information from image files  
libimage-exiftool-perl - Library and program to read and write meta information in multimedia files  
libimage-info-perl - allows extraction of meta information from image files  
metacam - extract EXIF information from digital camera files  
pyrenamer - mass file renamer written in PyGTK  
python-exif - Python library to extract EXIF data from tiff and jpeg files  
renrot - Rename and rotate files according to EXIF tags  

So try pyrenamer Install pyrenamer. If you can't make it do what you like, you might build your own tool with python-exif Install python-exif.

share|improve this answer
    
Thanks a lot. I totally didn't know about 'apt-cache search'. I ended up writing something with python-exiv2, and it works! –  Jon Dec 3 '11 at 23:15
add comment

As there is no other answer showing how to actually rename photos with the titles added in Shotwell, here is a quick way to script it using bash, as you say in the comments that you already have a python alternative. There may well be other ways of doing it, but this one might be useful for someone.

As you have already given your pictures a title in Shotwell and exported them, and found out where the metadata is stored that Shotwell adds, it is relatively straightforward to put a script together.

Please install libimage-exiftool-perl, as that will be necessary for the script.

1) If you use exiftool -a G1 -s pic.jpg, you can see all the metadata types and tags embedded within a picture, and also where Shotwell places the metadata:

[XMP-photoshop] Headline                        : 002
[XMP-dc]        Title                           : 002
[IPTC]          Caption-Abstract                : 002
[IPTC]          Headline                        : 002
[IPTC]          OriginatingProgram              : Shotwell
[IPTC]          ProgramVersion                  : 0.13.1+trunk

2) Now either the XMP-photoshop or the IPTC tags can be used with exiftool in our script to show the metadata (and then use that resulting value to rename the file).

Entering exiftool -IPTC:headline pic.jpg results in

Headline                        : 002

and this can be parsed with awk and fed back as the variable to rename the file:

mv -i "$i" "$(exiftool -IPTC:headline "$i" | awk -F ': ' '{print $2}').jpg"

3) The final script would be like this:

#!/bin/bash

for i in *.jpg
do 
    mv -i "$i" "$(exiftool -IPTC:headline "$i" | awk -F ': ' '{print $2}').jpg" 
done

So, now all your files have been renamed with their Shotwell titles, as we see when we examine one with exiftool -a -G1 -s pic.jpg:

ExifTool Version Number         : 9.12
File Name                       : 002.jpg

Notes:

  • The repository version of exiftool is fine, but is quite old, so if you need support for various new features and bugfixes, see the official site for how to build and install the more recent version.

  • All of the metadata is preserved unchanged by the script, as only the actual file itself is being renamed.

  • The script will obviously only work if your pictures have titles created with Shotwell embedded within them, but it could be adapted for other purposes.

  • There may also be an alternative way to do this with exiftool, without invoking awk, so I will investigate further.

For more general information, see man exiftool or the Ubuntu manpages online.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.