ExifTool Forum

ExifTool => Newbies => Topic started by: yzgyr on April 13, 2016, 11:47:30 AM

Title: rename and add _GPS_ if exif contains GPS data
Post by: yzgyr on April 13, 2016, 11:47:30 AM
Hi,
I would like to rename a bunch of images and add the type and GPS to the file name like this:

IF GPS DATA:
YYYYMMDD_HHMMSS_GPS_[IMAGE|VIDEO].%le

so far I got this

exiftool -d "./%Y/%m/%Y%m%d_%H%M%S%%-c.%%le" \
        '-filename<ModifyDate' \
        '-filename<CreateDate' \
        '-filename<DateTimeOriginal' \
        -r .

i tried -if "${GPSLatitude}" '-filename<DateTimeOriginal' but it doesn't work

Thank you,
yzgyr
Title: Re: rename and add _GPS_ if exif contains GPS data
Post by: Phil Harvey on April 14, 2016, 07:12:16 AM
Quote from: yzgyr on April 13, 2016, 11:47:30 AM
i tried -if "${GPSLatitude}" '-filename<DateTimeOriginal' but it doesn't work

I'm guessing that you're on a Mac.  If so, the hint you need is in my signature.

- Phil
Title: Re: rename and add _GPS_ if exif contains GPS data
Post by: yzgyr on April 14, 2016, 09:42:49 AM
Hi Phil,
I'm on a linux system and I tried the following but still no success.

exiftool -d "${DEST}/%Y/%m/%Y%m%d_%H%M%S%%-c.%%le" \
   '-filename<ModifyDate' '-filename<ModifyDate' \
   '-filename<CreateDate' '-filename<DateTimeOriginal}' \
   -if '${GPSLatitude}' '-filename<ModifyDate' \
   -if '${GPSLatitude}' '-filename<CreateDate' \
   -if '${GPSLatitude}' '-filename<DateTimeOriginal' \
   -r .
    8 directories scanned
  112 files failed condition
    0 image files read

I also tried

exiftool -d "${DEST}/%Y/%m/%Y%m%d_%H%M%S%%-c.%%le" \
   '-filename<ModifyDate' \
   '-filename<ModifyDate' \
   '-filename<CreateDate' \
   '-filename<DateTimeOriginal}' \
   -if '${GPSLatitude}' '-filename<${ModifyDate}_GPS%-c.%le' \
   -if '${GPSLatitude}' '-filename<${CreateDate}_GPS%-c.%le' \
   -if '${GPSLatitude}' '-filename<${DateTimeOriginal}_GPS%-c.%le' \
   -r ${SOURCE}
    8 directories scanned
  112 files failed condition
    0 image files read

-yzgyr
Title: Re: rename and add _GPS_ if exif contains GPS data
Post by: Phil Harvey on April 14, 2016, 10:18:10 AM
The -if option applies to the processing of each file, if the condition isn't satisfied then the file is not processed.   So you only need one -if option.

The files weren't processed because none of them had a GPSLatitude tag.

To do what you want in a single command will require a bit of trickery:

exiftool -d "${DEST}/%Y/%m/%Y%m%d_%H%M%S%%-c.%%le" \
   '-filename<ModifyDate' \
   '-filename<ModifyDate' \
   '-filename<CreateDate' \
   '-filename<DateTimeOriginal}' \
   '-filename<${ModifyDate}_${GPSLatitude;$_="GPS"}%-c.%le' \
   '-filename<${CreateDate}_${GPSLatitude;$_="GPS"}%-c.%le' \
   '-filename<${DateTimeOriginal}_${GPSLatitude;$_="GPS"}%-c.%le' \
   -r ${SOURCE}


- Phil