[Solved] Renaming photo files with IPTC Keywords; Charset problem ë

Started by wowo, August 13, 2013, 06:43:58 PM

Previous topic - Next topic

wowo

I want to rename my photo files with IPTC Keywords. The original name must not be changed.
My system is Linux (Ubuntu) and I am using Shotwell.

Example:
IPTC Keywords in Metadata: 2013, Kroatië, Novalja, Vakantie
Original name = DSC06974.JPG

Renaming all photo files within directory /home/silencio1/temp with the following code:
exiftool '-filename<%f_$Keywords.%e' /home/silencio1/temp

After renaming = DSC06974_2013, Kroatië, Novalja, Vakantie.JPG

I cannot find out how the "ë" could be renamed correct.

[edit] deleted "-exif=UTF8" from code; was not correct [/edit]

Phil Harvey

As long as the IPTC is encoded properly (preferably UTF-8 with CodedCharacterSet set), then your command should work on Mac/Linux (without the -exif=UTF8 which does nothing for many reasons).

What do you see in your terminal with this command?:

exiftool -keywords DSC06974.JPG

If your terminal uses UTF-8 and you see the proper special characters with the output from the above command, then this should work to rename the file:

exiftool '-filename<%f_$Keywords.%e' /home/silencio1/temp

I tried, and it works for me on my Mac.

But i would suggest perhaps adding -sep '_' to the command to use a different separator for the keywords.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

wowo

Sorry, I used the command without -exif=UTF8. The command with -exif=UTF8 did work but gived an warning:
Warning: Invalid EXIF data for EXIF:EXIF

Output exiftool '-filename<%f_$Keywords.%e' /home/silencio1/temp:
exiftool -keywords DSC06974.JPG
Keywords                        : 2013, Kroatië, Novalja, Vakantie

The following did for me the trick:
exiftool -L '-filename<%f_$Keywords.%e' /home/silencio1/temp

After that I insert _ and delete , with pyRenamer. Result:
DSC06974_2013_Kroatië_Novalja_Vakantie.JPG

Thanks for your help.

Phil Harvey

Glad the special characters work.  You don't need to use pyRenamer if you use the -sep option I mentioned earlier.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

wowo

Quote from: Phil Harvey on August 14, 2013, 07:24:29 AM
Glad the special characters work.  You don't need to use pyRenamer if you use the -sep option I mentioned earlier.
I do not know how I must use the -sep function in my code. That's why I have used pyRenamer.
I have tried a lot of options with -sep but none of them worked.
Example:
exiftool -L '-filename<%f_$Keywords -sep.%e' /home/silencio1/temp
After renaming:
DSC06974_2013, Kroatië, Novalja, Vakantie -sep.JPG
De separator in Shotwell for multiple keywords is ',' .
Can you maybe tell me how the code must be ?

Phil Harvey

The options work like this:

exiftool -L '-filename<%f_$Keywords.%e' -sep '_' /home/silencio1/temp

Read the ExifTool application documentation for a full list of options with lots of examples.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

wowo

Thanks for your reply.
One of the options I have tried was also your command. ;)

Unfortunately this command does not work.
The output is the same: DSC06974_2013, Kroatië, Novalja, Vakantie.JPG

I don't mind, I will do the last steps with pyRenamer.

Phil Harvey

If the output is the same then either you are using an old version of ExifTool or your keywords are not stored properly, and are stored together in a comma-separated string instead of separately as they should be.  In this case, the following command will work:

exiftool -L '-filename<%f_${Keywords;s/, /_/g}.%e' -sep '_' /home/silencio1/temp

I have left in the -sep option so the above command will work whether or not the Keywords are stored properly.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

wowo

This command is working very strange for me.
1 directories scanned
1 directories created
1 image files updated

A new directory is created with the name "DSC06974_2013, Kroatië, Novalja, Vakantie;s".
In that directory is stored another directory called ",". In that directory another directory with the name "_". In the last directory was the foto file with the renamed name "g}"
::)

These tags are made with Shotwell and are Hierarchical Tags.
Maybe this is why -sep is not working ?

Phil Harvey

Update your version of ExifTool, you must be using an old version.  The current version is 9.34.  The behaviour you describe will happen with version 9.14 or earlier.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

wowo

Ah!
I am using Ubuntu 12.04 lts.
It seems indeed that I have an very old version of exftool: 8.60
I will try your command with the correct recent version.

wowo


wowo

 :)
I have tried everything again in 13.04 Ubuntu running in virtualbox and now it is running well.
Output is DSC06974_2013_Kroatië_Novalja_Vakantie
I must find out myself what goes wrong in Ubuntu 12.04 ....
Again thanks for your help.

wowo

The commando:
exiftool -L '-filename<%f_$Keywords.%e' -sep '_' /home/silencio1/temp
is now working well in Ubuntu 12.04.
I think that the sytem was using the exiftool from the Hugin Panorama Creator.
After installing exif tool with your instructions, exiftool gave no problems.