Author Topic: Import and export of metadata  (Read 29591 times)

WJ

  • Newbie
  • *
  • Posts: 2
Import and export of metadata
« on: May 05, 2010, 02:41:45 AM »
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 Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17499
    • ExifTool Home Page
Re: Import and export of metadata
« Reply #1 on: May 05, 2010, 07:45:01 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

WJ

  • Newbie
  • *
  • Posts: 2
Re: Import and export of metadata
« Reply #2 on: May 05, 2010, 10:41:38 AM »
Thanks Phil.

larrysm

  • Newbie
  • *
  • Posts: 2
Re: Import and export of metadata
« Reply #3 on: March 25, 2011, 03:50:45 PM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17499
    • ExifTool Home Page
Re: Import and export of metadata
« Reply #4 on: March 25, 2011, 09:21:32 PM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

larrysm

  • Newbie
  • *
  • Posts: 2
Re: Import and export of metadata
« Reply #5 on: March 26, 2011, 10:58:59 PM »
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

  • Newbie
  • *
  • Posts: 1
Re: Import and export of metadata
« Reply #6 on: July 04, 2011, 12:46:56 PM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17499
    • ExifTool Home Page
Re: Import and export of metadata
« Reply #7 on: July 04, 2011, 01:45:16 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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

11august

  • Full Member
  • ***
  • Posts: 30
Re: Import and export of metadata
« Reply #8 on: August 07, 2016, 08:20:41 AM »
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
Code: [Select]
exiftool -r -csv ~/Desktop/Pictures >out.csv that will automatically keep the fraction numbers in the output .csv file?

Thanks!! :)



Hayo Baan

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 1140
  • Professional Photographer & Software Developer
    • Hayo Baan – Photography
Re: Import and export of metadata
« Reply #9 on: August 07, 2016, 09:06:53 AM »
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:
Code: [Select]
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:
Code: [Select]
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

  • Full Member
  • ***
  • Posts: 30
Re: Import and export of metadata
« Reply #10 on: August 09, 2016, 07:30:50 AM »
Hello Hayo and many thanks for the explanations and the code. It makes perfect sense!

Another question about the original code given by Phil:

Code: [Select]
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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 4456
Re: Import and export of metadata
« Reply #11 on: August 09, 2016, 11:21:55 AM »
Is 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:
Code: [Select]
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
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

11august

  • Full Member
  • ***
  • Posts: 30
Re: Import and export of metadata
« Reply #12 on: August 10, 2016, 01:43:36 PM »
Thank you! It works perfectly!

 8)