Skip to content

Instantly share code, notes, and snippets.

@ejm554
Created February 17, 2019 21:16
Show Gist options
  • Save ejm554/ee5a87fe047f6a1dc36a5858f2f11bd4 to your computer and use it in GitHub Desktop.
Save ejm554/ee5a87fe047f6a1dc36a5858f2f11bd4 to your computer and use it in GitHub Desktop.

EXAMPLES OF EXPRESSIONS IN EXIFTOOL

  • Author: EJ Makela
  • Creation Date: 2019-02-17

INTRODUCTION

ExifTool allows a user to use "Perl-like" expressions to search and replace text in tags. In the following examples, a file ("image.jpg") was processed using a variety of different strings to see how the results would differ.

The following command was executed, with EXPR substituted with the expression listed in the first column of the table. The values in that column alternate between the substitution operator (s///) or the translation operator (tr///).

$ exiftool -p '${FileName;EXPR}' image.jpg

TABLE

EXPR RESULT FILE-EXT INVALIDATED? SEE NOTE
s/image/abcd/ abcd.jpg
tr/image/abcd/ abcdd.jpd YES
s/aegim/abcd/ image.jpg 1
tr/aegim/abcd/ ddacb.jpc YES 1
s/image/12345/ 12345.jpg
tr/image/12345/ 12345.jp4 YES
s/image/1234/ 1234.jpg
tr/image/1234/ 12344.jp4 YES
s/image/123456/ 123456.jpg
tr/image/123456/ 12345.jp4 YES 2

NOTES

  1. "aegim" is alphabetized string of "image".
  2. ExifTool error: "Warning: Replacement list is longer than search list for 'filename' - image.jpg"

MORE INFO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment