Call exiftool from Python - basics

1.6k views Asked by At

I would like to call exiftool in Windows 7 from within a python script to both extract and add info to the image tags, but I'm stumbling over the basic workflow to do this. This question and answer addresses this topic, but I have a couple of basic questions regarding it and am unable to comment on the original question:

  1. Where on my system should the executable be stored?
  2. What does the *filenames bit do?
  3. Can I just specify a list of files in place of *filenames in the 'with ExifTool()' bit, or should I just leave it as is and make sure my directory with my images is my cwd?

Any help is appreciated!

1

There are 1 answers

2
vikramls On
  1. The executable can be stored anywhere on your system - just make sure to pass the path to the ExifTool constructor when you create it:

    with ExifTool('') as e: metadata = e.get_metadata(*filenames)

  2. *filenames is syntax for "exploding" a list (in this example). Rather than passing a single list with filenames to the self.execute call, we pass all the filenames as part of the *args.

  3. You can specify a list of filenames if you want - filenames just needs to be a list of paths for exiftool to process.