ExifTool Forum

ExifTool => Newbies => Topic started by: A1GSS on June 01, 2015, 04:13:34 AM

Title: Build exiftool workflow with Automator on OSX Yosemite
Post by: A1GSS on June 01, 2015, 04:13:34 AM
Hi

I'm new to exiftool and I'm no programmer, so please bear with me  :)  It's amazingly powerful and flexible, and I'm finding it a bit daunting.

I have a simple requirement, which is (1) to add createdate exif data to scanned images that don't have it. If possible I'd like to then increment the timestamp by one minute on each image in the selected range. And then (b) change the file create date to match. 

Apart from incrementing the timestamp I know that I can do what I need to do using exiftool in terminal, and have tested it and it works.  Here are my two exiftool commands so far:

exiftool -createdate="YYYY:MM:DD HH:MM:SS" DIR
exiftool "-filemodifydate<createdate" DIR


(by the way, I tried exiftool "-filecreatedate<createdate" DIR and I couldn't get it to work...?)

If possible I'd like to then increment the timestamp by one minute on each image in the selected range, but I've not figured out to do that. If I can get this working I'd do it before the sync of the file dates and exif dates?

I've got about 10,000 to do. I want to build an automator workflow (or service) that takes away the manual editing of the exiftool arguments each time and the need to use terminal. I think I can do this using a shellscript to execute the exiftool work, and to pass the arguments to it in automator somehow. I always take a full backup before starting work so I don't want to make copies of the files before exiftool touches them.

So what I want to do is as follows.

1. Select a bunch of files in the finder
2. Invoke the workflow
3. Prompt for date, and the timestamp wanted on the first file in the selection
4. Request confirmation
5. Apply changes to files
6. End

Any help especially with the prompting for date/time, passing those arguments and finder output to the shellscript, and the script itself very welcome.

Thanks very much.


Graham
Title: Re: Build exiftool workflow with Automator on OSX Yosemite
Post by: Phil Harvey on June 01, 2015, 07:04:57 AM
Hi Graham,

Quote from: A1GSS on June 01, 2015, 04:13:34 AM
(by the way, I tried exiftool "-filecreatedate<createdate" DIR and I couldn't get it to work...?)

This should work if you are on Windows.  It doesn't work for Mac or Linux.

QuoteIf possible I'd like to then increment the timestamp by one minute on each image in the selected range, but I've not figured out to do that. If I can get this working I'd do it before the sync of the file dates and exif dates?

The forum search feature is you friend. :)  Take a look here. (https://exiftool.org/forum/index.php/topic,5621.msg27394.html#msg27394)

Quote1. Select a bunch of files in the finder
2. Invoke the workflow
3. Prompt for date, and the timestamp wanted on the first file in the selection
4. Request confirmation
5. Apply changes to files
6. End

Any help especially with the prompting for date/time, passing those arguments and finder output to the shellscript, and the script itself very welcome.

Ah.  You're on Mac then?  If you can figure out the exact commands you want to use, I can help you put them together in a shell script.  You can ask for user input in a sh script like this:

read -p "Is this OK [y/n]? " ok
if [ "x$ok" != 'xy' ]; then
    echo 1>&2 'Aborted!'
    exit 127
fi


Here the "x" in the comparison may not be necessary, but I have always done this because I have had problems with empty strings in shell scripts in the past.

- Phil
Title: Re: Build exiftool workflow with Automator on OSX Yosemite
Post by: A1GSS on June 01, 2015, 08:26:36 AM
Hi Phil

Thanks very much for the reply. Yes, on Mac, so filecreatedate can't be set then. Given the power of exiftool I can only assume that is a weakness / characteristic of the Mac...

Also datetimeoriginal didn't do anything with that filesequence increment example, it gives me

    1 directories scanned
    0 image files updated
    6 image files unchanged

I've just retried that using createdate and it works.

So my three exiftool commands in sequence are

exiftool -createdate="YYYY:MM:DD HH:MM:SS" DIR
exiftool '-createdate+<0:$filesequence' DIR
exiftool "-filemodifydate<createdate" DIR




Title: Re: Build exiftool workflow with Automator on OSX Yosemite
Post by: Phil Harvey on June 01, 2015, 11:29:33 AM
Hi Graham,

Quote from: A1GSS on June 01, 2015, 08:26:36 AM
Given the power of exiftool I can only assume that is a weakness / characteristic of the Mac...

Platform-dependent things like this aren't well supported.  Unix doesn't store the file creation date, so this can't be set using the basic Perl libraries, and I haven't yet found a good way to do this on the Mac.

QuoteAlso datetimeoriginal didn't do anything with that filesequence increment example

The DateTimeOriginal tag must exist for this to work.  You are writing CreateDate, so you should use this instead as you discovered.

- Phil
Title: Re: Build exiftool workflow with Automator on OSX Yosemite
Post by: A1GSS on June 01, 2015, 12:18:43 PM
Hi

Right thanks. Got it.

QuoteThe DateTimeOriginal tag must exist for this to work.  You are writing CreateDate, so you should use this instead as you discovered.
Dah! That's in the realms of the ****ing obvious, sorry. Numpty.

I'm making some progress on the automator / shellscript side but think I need someone along who knows much about it. I'm sure it's almost there. The shellscript I've got accepts selected finder item(s) as an argument and now looks like this:

for f
do
exiftool -createdate='1983:10:12 14:00:00' "$f"
exiftool '-createdate+<0:$filesequence' "$f"
exiftool "-filemodifydate<createdate" "$f"
done



but it fails with "File not found - " and then the filename that I was passing in. Which is there as it's selected, and the Automator action i'results' window shows me the correct file or files or folder.



Title: Re: Build exiftool workflow with Automator on OSX Yosemite
Post by: Phil Harvey on June 01, 2015, 12:25:01 PM
Hi Graham,

Are you specifying the absolute path of the file?  If not, you need to worry about the current working directory for your script.  If it is absolute, then I can't think of why it wouldn't work.

- Phil
Title: Re: Build exiftool workflow with Automator on OSX Yosemite
Post by: A1GSS on June 01, 2015, 01:03:48 PM
It's passed through correctly as a full path, but here's a thing.  I've just redone it (started again) and with fresh thought and some better understanding it's working when I give it a folder as the input.  :)

I also had to split the loop into three. Process the first as a loop, take the middle line out, it didn't do anything where it was. and execute on its own, then another loop. So now it looks like this:

for f
do
   exiftool -createdate='1988:04:11 12:30:00'  "$f"
done
exiftool '-createdate+<0:$filesequence' "$f"
for f
do
   exiftool "-filemodifydate<createdate"  "$f"
done


So now I have to figure out why this bit exiftool '-createdate+<0:$filesequence' "$f" doesn't work if the script is fed a selection of files.  I think it's because it processes each one in turn, so if there's only one then it won't touch it.

Progress though. So thank you.
Title: Re: Build exiftool workflow with Automator on OSX Yosemite
Post by: Phil Harvey on June 01, 2015, 01:13:45 PM
Oh, right.  FileSequence is the sequence of files in a single command.  So if you are only running one file, this tag will always be zero.

You need to do them all at once.  Put all the names on the same command line if you want to specify the files individually.

- Phil
Title: Re: Build exiftool workflow with Automator on OSX Yosemite
Post by: A1GSS on June 01, 2015, 01:25:25 PM
OK thanks, got it. No idea how I do that in Automator. Anyways I'm in a much better place now :-)
Title: Re: Build exiftool workflow with Automator on OSX Yosemite
Post by: Alan Clifford on June 02, 2015, 03:49:45 AM
Quoteexiftool '-createdate+<0:$filesequence' "$f"

I've never used this automator thingy but it looks like bash.  If there are a lot of filenames being passed, which it looks like there are, as you can use "for f", I think this might do it"

exiftool '-createdate+<0:$filesequence' "$@"

Hmmm,  thinks, could you use this syntax for the other exiftool commands without using the for loop?

Title: Re: Build exiftool workflow with Automator on OSX Yosemite
Post by: A1GSS on June 02, 2015, 05:14:10 AM
Hi Alan

EDIT: Just reread your post again again again..

Thanks.  Automator is a simple workflow tool for Mac OSX. Ideal for numpties like me.
http://en.wikipedia.org/wiki/Automator_(software)

I'll try your very excellent suggestion with thanks!
Title: Re: Build exiftool workflow with Automator on OSX Yosemite
Post by: A1GSS on June 02, 2015, 02:13:38 PM
Well I've tested it and like most simple things it works brilliantly, so thank you :-) It accepts folder, or a bunch of files as input. If a folder is input it does all the files. If some files are selected it only touches those. Non-contiguous files work just as well as blocks.

I now have this three liner:

exiftool -createdate='2004:13:25 17:12:00'  "$@"  -overwrite_original
exiftool '-createdate+<0:$filesequence' "$@"  -overwrite_original
exiftool "-filemodifydate<createdate"  "$@"  -overwrite_original


So call me a happy bear.

Title: Re: Build exiftool workflow with Automator on OSX Yosemite
Post by: A1GSS on June 02, 2015, 02:16:26 PM
Also, as another benefit I'd say it's at least twice as fast  :)