smarnach / pyexiftool

a Python library to communicate with an instance of Phil Harvey's excellent ExifTool command-line application.
Other
270 stars 111 forks source link

Date Formating (-d) Appears to Be Ignored #42

Closed gazingbazooka closed 1 year ago

gazingbazooka commented 1 year ago

Launching the tool in Python it appears to be ignoring the "-d" parameter for the date format and just using the internal default.

with ExifToolHelper(logger = logger) as et: result = et.execute("-verbose", "-d", "%Y%m%d-%H%M%S%%-c.%%e", "-FileName<DateTimeOriginal", sub_dir)

Verbose, Filename and the directory are all accounted for and no error is logged

DEBUG:root:ExifToolHelper.execute: IN params = ('-verbose', '-d', '%Y%m%d-%H%M%S%%-c.%%e', '-FileName<DateTimeOriginal', './import') DEBUG:root:ExifToolHelper.execute: OUT stdout = "======== ./import/20230128084030-20230127223016-REDACTED_12.jpg Setting new values from ./import/20230128084030-20230127223016-REDACTED_12.jpg './import/20230128084030-20230127223016-REDACTED_12.jpg' --> './import/2004:01:29 14:35:03' ======== ./import/20230128084030-20230127223016-REDACTED_06.jpg Setting new values from ./import/20230128084030-20230127223016-REDACTED_06.jpg './import/20230128084030-20230127223016-REDACTED_06.jpg' --> './import/2004:01:29 14:18:24'

The following seems to work just fine:

exiftool_command = ["exiftool", "-verbose", "-d", "%Y%m%d-%H%M%S%%-c.%%e", "-FileName<DateTimeOriginal", sub_dir] process = subprocess.run(exiftool_command)

Almost same issue as this but they had a missed comma between the parameters:

https://stackoverflow.com/questions/74305074/renaming-image-files-with-pyexiftool-0-5-4-exiftool-in-python

MacOS 12.6.2 Exiftool 12.52 PyExifTool 0.5.5 Python 3.10.4

sylikc commented 1 year ago

the only thing that is being left off by using the command by itself is the -n flag. You can get the same behavior that you're expecting by with ExifToolHelper(common_args=[])

sylikc commented 1 year ago

see if that fixes the problem

gazingbazooka commented 1 year ago

Confirmed working! Did I miss some documentation about this? I'm not clear why my original wouldn't work.

sylikc commented 1 year ago

Confirmed working! Did I miss some documentation about this? I'm not clear why my original wouldn't work.

Oh, I just noticed this isn't an issue on my page.

well, given you're using ExifToolHelper() you're using my version, homepage here https://github.com/sylikc/pyexiftool

The docs here is explains the common_args behavior https://sylikc.github.io/pyexiftool/reference/1-exiftool.html#exiftool.ExifTool.__init__

I ever wrote an FAQ to explain the exact situation https://sylikc.github.io/pyexiftool/faq.html#what-s-going-on 😁