News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Import and export of metadata

Started by WJ, May 05, 2010, 02:41:45 AM

Previous topic - Next topic

WJ

Hi,

is Exiftool able to import iptc, exif and xmp metadata from the file format xml, excel and txt/csv into image files (BATCH)?

Is Exiftool abel to export iptc, exif  and xmp metadata from image files to the file formats xml, excel and txt/csv (BATCH)?

Best Regards,

WJ

Phil Harvey

ExifTool can export information in any format you want using the -p option.  It also has built-in support for writing in RDF/XML and JSON format.  (All batch)

ExifTool will import from the RDF/XML files that it writes, but won't import from arbitrary XML files.

Importing from CSV files can only be done by writing a bit of Perl script yourself.  If you search this forum you should find some examples of this.

ExifTool doesn't read data from excel worksheets.

- 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 ($).

WJ


larrysm

Hi I'm a little confused - may be old information but the manual for exiftool has a paragraph about importing from csv files built in :

" # update metadata for all images in a directory from CSV file
    exiftool -csv=a.csv dir"

I've been playing with the -csv tag... I can get the export to work, but I can't get the import to work. Is this functional, and if so, could someone please provide another example, because the one I pasted is not working for me. Maybe I'm missing something.

thanks
Larry

Phil Harvey

Hi Larry,

The -csv option is very new, and was added in version 8.51.

Export and import are both fully functional in versions 8.51 or later.

The syntax you have is correct.  In the example, "dir" represents the name of the directory containing the images.  If you can tell me specifically what you are trying to do and what you have done I should be able to help.

- 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 ($).

larrysm

Thanks Phil.
I was having trouble specifying the directory correctly in windows - advice for other beginners like me:
move all your photos to directories with short names right in your c: drive.. like "c:/images"
don't try using command line on something like c:/users/Name/my documents/my albums/images this will lead to errors.

great tool phil. if the GUI tool could incorporate the new csv functionality, that would be awesome.

KenCamera

Phil,

Forgive me for being so dense, I'm new to your tool.  What exactly does this mean?

"ExifTool can export information in any format you want using the -p option"

What I'm looking to do is perform a total data dump (all fields, all files - where the first row of the output contains the field tag names) of all files from a given directory "~/Desktop/Pictures" into a single csv output file that I can load into a database.  Do you have the exact command that I would need to write in Terminal to achieve that?

It seems like I'm very close, it scans the files but doesn't generate the csv file.  Here's what I've been typing:

exiftool -f -r -p my.csv ~/Desktop/Pictures > out.csv



Any halp you can provide would be greatly appreciated.

Phil Harvey

Quote from: KenCamera on July 04, 2011, 12:46:56 PM
"ExifTool can export information in any format you want using the -p option"

What I'm looking to do is perform a total data dump (all fields, all files - where the first row of the output contains the field tag names) of all files from a given directory "~/Desktop/Pictures" into a single csv output file that I can load into a database.  Do you have the exact command that I would need to write in Terminal to achieve that?

It seems like I'm very close, it scans the files but doesn't generate the csv file.  Here's what I've been typing:

exiftool -f -r -p my.csv ~/Desktop/Pictures > out.csv

The -p option is used to format the output for a specified set of tags, so it isn't what you want because it won't output all available tags.

I think you are looking for the -csv option, which works like this:

exiftool -r -csv ~/Desktop/Pictures >out.csv

- 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 ($).

11august

Hi Phil,

Sorry for the unearthing topic, but this is exactly what I needed for my project.

However, I have a problem with the .csv output file as some fraction numbers ("x/xx") appears to automatically be converted onto a format date ("mmmm-yy") in some fields (such as "ShutterSpeed" for example).

I thought at first that I could correct the problem directly in the .csv file, but there's no reliable solution that is able to convert all the correct fields in the correct format. Either it convert it in a large number if I choose the text option or I have to manually correct all the cells which is not possible at all as I have very large .csv files (thousands of cells...).

So do you have any code that I could add to exiftool -r -csv ~/Desktop/Pictures >out.csv that will automatically keep the fraction numbers in the output .csv file?

Thanks!! :)



Hayo Baan

The problem is not the CSV, it is the spreadsheet program you are using. Usually when importing or pasting CSV data, you get an option on how to treat the (column) data. Look for an option that reads detect special numbers (deselect it), or change the format of the pasted column to e.g. Text. Another solution would be to surround the columns with fractions with double quotes (when importing these are normally always treated as text). This you could do with a little perl magic:
exiftool -r -csv ~/Desktop/Pictures | perl -p -E 's#(\d+/\d+)#"$1"#g' >out.csv

If, which is what I think you really want, you actually want the fractions to come out as real numbers (e.g. 1/4 = 0.25), then this can be done with a little perl magic too:
exiftool -r -csv ~/Desktop/Pictures | perl -p -E 's#(\d+)/(\d+)#$1/$2#ge' >out.csv

Hope this helps,
Hayo

P.S. Since you refer to the Desktop using ~/Desktop... I assume you are running on a Mac, in which case the commands I proposed can be used without alteration.
Hayo Baan – Photography
Web: www.hayobaan.nl

11august

Hello Hayo and many thanks for the explanations and the code. It makes perfect sense!

Another question about the original code given by Phil:

exiftool -r -csv ~/Desktop/Pictures >out.csv

It extract all the metadata in the .csv file, but for my project I only need some of these (the technical and common parameters of the camera/picture in fact, such as shutterspeed value, f number, ISO, etc...). Is there a way to tell EXIFTool to extract only these?

Thank you!


StarGeek

Quote from: 11august on August 09, 2016, 07:30:50 AMIs there a way to tell EXIFTool to extract only these?

Yes, you just add them in using the TAG option.  You just have to figure out what the actual tag names are.  You can do that with the exiftool -s -g1 -a command.  For example, here's a bit of output from that command on a file:
ExposureTime                    : 1/20
FNumber                         : 5.6
ExposureProgram                 : Not Defined
ISO                             : 3200
SensitivityType                 : Recommended Exposure Index
DateTimeOriginal                : 2011:08:03 16:08:07
CreateDate                      : 2011:08:03 16:08:07
ExposureCompensation            : 0
MaxApertureValue                : 5.7
MeteringMode                    : Multi-segment
LightSource                     : Unknown
Flash                           : Off, Did not fire
FocalLength                     : 105.0 mm


If you wanted ExposureTime, ISO, and FocalLength, then your command would be
exiftool -r -csv ~/Desktop/Pictures >out.csv -ExposureTime -ISO -FocalLength
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

11august