Skip to content

Commit 6ecb2f7

Browse files
committed
add support for lists in tags.items in set_tags_batch()
(check CHANGELOG.md for more information) fixes GitHub issue #12 , code contributed by @davidorme in #12 (comment)
1 parent 7bf3c17 commit 6ecb2f7

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ Date (Timezone) | Version | Comment
2727
02/01/2020 05:09:43 PM (PST) | 0.4.1 | incorporated pull request #2 and #3 by ickc which added a "no_output" feature and an import for ujson if it's installed. Thanks for the updates!
2828
04/09/2020 04:25:31 AM (PDT) | 0.4.2 | roll back 0.4.0's pyexiftool rename. It appears there's no specific PEP to have to to name PyPI projects to be py<something>. The only convention I found was https://www.python.org/dev/peps/pep-0423/#use-standard-pattern-for-community-contributions which I might look at in more detail
2929
04/09/2020 05:15:40 AM (PDT) | 0.4.3 | initial work of moving the exiftool.py into a directory preparing to break it down into separate files to make the codebase more manageable
30-
03/12/2021 01:37:30 PM (PDT) | 0.4.4 | no functional code changes. Revamped the setup.py and related files to release to PyPI. Added all necessary and recommended files into release
31-
03/12/2021 02:03:38 PM (PDT) | 0.4.5 | no functional code changes. re-release with new version because I accidentally included the "test" package with the PyPI 0.4.4 release. I deleted it instead of yanking or doing a post release this time... just bumped the version. "test" folder renamed to "tests" as per convention, so the build will automatically ignore it
30+
03/12/2021 01:37:30 PM (PST) | 0.4.4 | no functional code changes. Revamped the setup.py and related files to release to PyPI. Added all necessary and recommended files into release
31+
03/12/2021 02:03:38 PM (PST) | 0.4.5 | no functional code changes. re-release with new version because I accidentally included the "test" package with the PyPI 0.4.4 release. I deleted it instead of yanking or doing a post release this time... just bumped the version. "test" folder renamed to "tests" as per convention, so the build will automatically ignore it
32+
04/08/2021 03:38:46 PM (PDT) | 0.4.6 | added support for config files in constructor -- Merged pull request #7 from @asielen and fixed a bug referenced in the discussion https://github.com/sylikc/pyexiftool/pull/7
33+
04/19/2021 02:37:02 PM (PDT) | 0.4.7 | added support for writing a list of values in set_tags_batch() which allows setting individual keywords (and other tags which are exiftool lists) -- contribution from @davidorme referenced in issue https://github.com/sylikc/pyexiftool/issues/12#issuecomment-821879234
34+
3235

3336
On version changes, update setup.py to reflect version
3437

exiftool/exiftool.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,9 @@ def set_tags_batch(self, tags, filenames):
663663
:py:meth:`execute()`.
664664
665665
It can be passed into `check_ok()` and `format_error()`.
666+
667+
tags items can be lists, in which case, the tag will be passed
668+
with each item in the list, in the order given
666669
"""
667670
# Explicitly ruling out strings here because passing in a
668671
# string would lead to strange and hard-to-find errors
@@ -676,7 +679,15 @@ def set_tags_batch(self, tags, filenames):
676679
params = []
677680
params_utf8 = []
678681
for tag, value in tags.items():
679-
params.append(u'-%s=%s' % (tag, value))
682+
# contributed by @daviddorme in https://github.com/sylikc/pyexiftool/issues/12#issuecomment-821879234
683+
# allows setting things like Keywords which require separate directives
684+
# > exiftool -Keywords=keyword1 -Keywords=keyword2 -Keywords=keyword3 file.jpg
685+
# which are not supported as duplicate keys in a dictionary
686+
if isinstance(value, list):
687+
for item in value:
688+
params.append(u'-%s=%s' % (tag, item))
689+
else:
690+
params.append(u'-%s=%s' % (tag, value))
680691

681692
params.extend(filenames)
682693
params_utf8 = [x.encode('utf-8') for x in params]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
# overview
3232
name="PyExifTool",
33-
version="0.4.5",
33+
version="0.4.7",
3434
license="GPLv3+/BSD",
3535
url="http://github.com/sylikc/pyexiftool",
3636
python_requires=">=2.6",

0 commit comments

Comments
 (0)