ExifTool Forum

ExifTool => Developers => Topic started by: Joanna Carter on August 26, 2018, 06:32:46 AM

Title: Swift wrapper
Post by: Joanna Carter on August 26, 2018, 06:32:46 AM
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?
Title: Re: Swift wrapper
Post by: Joanna Carter on August 26, 2018, 07:00:57 AM
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 :-\
Title: Re: Swift wrapper
Post by: Joanna Carter on August 26, 2018, 07:09:36 AM
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
    }
Title: Re: Swift wrapper
Post by: angus on February 27, 2024, 11:54:00 PM
Joanna, did you ever publish your swift wrapper package for exiftool?