Main Menu

Swift wrapper

Started by Joanna Carter, August 26, 2018, 06:32:46 AM

Previous topic - Next topic

Joanna Carter

OK. I now have the majority of ExifTool encapsulated in a Swift wrapper API for developing in Xcode.

At the moment, I have one complex command that takes a hierarchy of files and sorts them into a target directory, organised by year, month, day.

If I run this on Nikon RAW files (.nef), no problem but, if I run it on jpeg files, using DateTimeOriginal, the date folder it gets put in isn't the same as the date shown in the file information shown in Finder

Any ideas?

Joanna Carter

Forget it  ::)

Obviously the date shown in Finder is the date the jpg file was created, possibly as a copy or edited version.

If I compare the date used by DateTimeOriginal with the "creation date" in ExifEditor, it matches fine.

That'll teach me to work on this project instead of getting the house ready for a guest  :o :-\

Joanna Carter

Possible of interest to those who are developing in Swift, here is an example of the code needed to create an Exif Command from code

The original command line is:

exiftool -P -r -m -q -q -ext JPG -o . '-Directory<DateTimeOriginal' -d /Users/joannacarter/Pictures/%Y/%m/%d /Volumes/Joanna\ C/DCIM/

The Swift code is:

    var arguments: [Argument] = [.preserveFileModificationDateTime,
                                 .recurse,
                                 .ignoreMinorErrors,
                                 .quietWarnings,
                                 .extension("jpg", exclude: false),
                                 .outputFlag,
                                 .currentDirectory,
                                 .directoryFromTag(Exif.dateTimeOriginal),
                                 .dateFormatFlag,
                                 .directoryWithFormat(url: destinationURL, formatSpecifiers: [.year, .month, .day]),
                                 .directory(sourceURL)]

    do
    {
      try execute(with: arguments)
    }
    catch
    {
      throw Error.couldNotCopyAndOrganiseFiles
    }

angus

Joanna, did you ever publish your swift wrapper package for exiftool?