Author Topic: Remove custom symbols  (Read 516 times)

Andrei Korzhyts

  • Sr. Member
  • ****
  • Posts: 236
Remove custom symbols
« on: July 15, 2019, 03:30:31 PM »
Hi.

1. I'm trying to create a template to remove spaces and hyphens. Here is my option:
exiftool "-TestName<${Model;s/ //g;s/-//g}" .
But I don't understand the purpose of "g".

2. Also, I don't understand fundamental difference between "tr" and "s" in the example from the documentation:
exiftool -p '${make;tr/ /_/;s/__+/_/g}' image.jpg
What are the cases where we can't use "s" instead of "tr"?

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3795
Re: Remove custom symbols
« Reply #1 on: July 15, 2019, 03:51:03 PM »
But I don't understand the purpose of "g".

The g stands for global.  Without it the substitution would stop after the first match.  For example if your regex was s/-// (no g), then "if-this-than-that" would be "if this-than-that", while with the g, it would be "if this than that".

Quote
2. Also, I don't understand fundamental difference between "tr" and "s" in the example from the documentation:
exiftool -p '${make;tr/ /_/;s/__+/_/g}' image.jpg
What are the cases where we can't use "s" instead of "tr"?

tr is the transliterate operator.  It replaces individual characters only. So if your example make was "Three   Spaces   Inbetween", then tr/ /_/ returns "Three___Spaces___Inbetween".  On the other hand, the other option is regex substitution.  It works likes this s/SearchTerm/Replacement/.  In the example s/__+/_/g it searches for an underscore (_) followed one or more underscores (_+).  The plus sign stands for 1 or more of the previous character.  So this command would take two or more underscores and globally replace them by a single underscore.  "Three___Spaces___Inbetween" becomes "Three_Spaces_Inbetween".
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.

Andrei Korzhyts

  • Sr. Member
  • ****
  • Posts: 236
Re: Remove custom symbols
« Reply #2 on: July 15, 2019, 04:35:17 PM »
Спасибо за ответ.
It is very difficult to learn everything in a foreign language.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3795
Re: Remove custom symbols
« Reply #3 on: July 15, 2019, 06:36:54 PM »
Sorry I can't be more helpful.  I tried to learn Russian years ago and failed spectacularly.  The only thing I remember is, roughly translated, "I don't know", "I don't understand" and "Please pass the glass".
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.

Andrei Korzhyts

  • Sr. Member
  • ****
  • Posts: 236
Re: Remove custom symbols
« Reply #4 on: July 15, 2019, 07:02:06 PM »
"Please pass the glass".
You were taught by Russians when you drank vodka? :)

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3795
Re: Remove custom symbols
« Reply #5 on: July 15, 2019, 07:06:33 PM »
Heh, nope.  I'm a non-drinker.  I have no idea why that one stuck with me.
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.

Andrei Korzhyts

  • Sr. Member
  • ****
  • Posts: 236
Re: Remove custom symbols
« Reply #6 on: July 15, 2019, 07:17:49 PM »
I'm also a non-drinker and non-smoker.
Real Russians do not drink and are not proud of vodka.
Ещё раз спасибо за ответы.