ExifTool Forum

ExifTool => Newbies => Topic started by: Fulco on April 07, 2016, 09:39:45 AM

Title: "Escape" dollar sign and/or single quotes
Post by: Fulco on April 07, 2016, 09:39:45 AM
With the -p option I print command lines which I can apply to other files. For example:

exiftool -q -q -m -n -if 'not $GPSLatitude =~/-/i and not $GPSLongitude =~/-/i' -p 'exiftool -GPSLatitude="$GPSLatitude" -GPSLatitudeRef="North" -GPSLongitude="$GPSLongitude" -GPSLongitudeRef="East" -overwrite_original -P ' -execute -q -q -m -n -if '$GPSLatitude =~/-/i  and not $GPSLongitude =~/-/i' -p 'exiftool -GPSLatitude="$GPSLatitude" -GPSLatitudeRef="South" -GPSLongitude="$GPSLongitude" -GPSLongitudeRef="East" -overwrite_original -P ' -execute -q -q -m -n -if 'not $GPSLatitude =~/-/i and $GPSLongitude =~/-/i' -p 'exiftool -GPSLatitude="$GPSLatitude" -GPSLatitudeRef="North" -GPSLongitude="$GPSLongitude" -GPSLongitudeRef="West" -overwrite_original -P ' -execute -q -q -m -n -if '$GPSLatitude =~/-/i and $GPSLongitude =~/-/i' -p 'exiftool -GPSLatitude="$GPSLatitude" -GPSLatitudeRef="South" -GPSLongitude="$GPSLongitude" -GPSLongitudeRef="West" -overwrite_original -P ' -common_args

What I also want to do is to print a command which contain dollar signs and/or single quotes. Is that possible?

- Fulco
Title: Re: "Escape" dollar sign and/or single quotes
Post by: Phil Harvey on April 07, 2016, 09:58:02 AM
Hi Fulco,

In the exiftool -p argument, "$$" may be used to print "$".

How to generate a single quote inside single quotes depends on what shell you are using.

- Phil
Title: Re: "Escape" dollar sign and/or single quotes
Post by: Fulco on April 07, 2016, 10:17:04 AM
Hello Phil,

I use the Terminal app on my Mac if that is what you mean. I've already tried a back slash but it didn't work.

- Fulco
Title: Re: "Escape" dollar sign and/or single quotes
Post by: Phil Harvey on April 07, 2016, 10:32:07 AM
Quote from: Fulco on April 07, 2016, 10:17:04 AM
I use the Terminal app on my Mac if that is what you mean.

No, I mean the shell running the terminal.  I use tcsh, but I think bash is default for recent versions of OS X.

I don't know if this is the best way, but this works in bash to get a single quote:

> exiftool -echo 'here'"'"'s a test'
here's a test


This also works:

> exiftool -echo 'here'\''s a test'
here's a test


- Phil
Title: Re: "Escape" dollar sign and/or single quotes
Post by: Fulco on April 07, 2016, 10:39:25 AM
Thank you!  It works. It is indeed bash.

- Fulco