Scripting GC - how to get from file name to window?

Having tech problems? Post them here and do not worry, there is always a solution for you.
Post Reply
chrillek
Posts: 18
Joined: Sun Nov 08, 2020 4:07 pm
Country: Germany

Scripting GC - how to get from file name to window?

Post by chrillek »

Hi, I'm trying to write a (JavaScript) script to work with the currently selected files in GC. It's simple to get the current selection like so

Code: Select all

var app = Application("GraphicConverter 11");
var sel = app.windows[0].selection()
Now, sel is an array ("list" in AppleScript parlance) containing the file names of the selected images. If I understand the GC script dictionary correctly, almost all methods and properties are bound to the Window object and not accessible if only a file name is available.

How would I go about to (for example) set the property "IPTC credit text" (bound to Window) if all I have is a file name? If somebody knows how to do that in AppleScript, that's fine too – I'll manage to translate that.
User avatar
forum_adm
Site Admin
Posts: 1814
Joined: Fri Dec 23, 2016 9:41 am
Location: Germany
Country: Germany
Contact:

Re: Scripting GC - how to get from file name to window?

Post by forum_adm »

Hi,

what do you want to script exactly?

Metadata should be changed without opening the file. This avoids recompression.

Thorsten
chrillek
Posts: 18
Joined: Sun Nov 08, 2020 4:07 pm
Country: Germany

Re: Scripting GC - how to get from file name to window?

Post by chrillek »

This is more an educational then a real project. I figured out how to get at the file's meta data in the mean time (although the documentation is a bit terse on that – that I have to use

Code: Select all

exifInfo['88250002']
(in JavaScript) to get the latitude, took some experimentation).

The idea for the script was reverse geocoding (i.e. fill in the country/city IPTC fields from the GPS EXIF data). As I said, educational, since GC knows how to do that already anyway. I found a way to _get_ the data in node.js, but that is so slow that it's not practical.
Post Reply