rename and add _GPS_ if exif contains GPS data

Started by yzgyr, April 13, 2016, 11:47:30 AM

Previous topic - Next topic

yzgyr

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

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

yzgyr

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

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).