Export Original settings: how to change destionation folder and image name?
Hi all,
I am a newbie of AS and have been trying to make a script that does "export originals" of rated variants.
I could change "packed" and "include adjustments" of export original settings but no success to change "destination folder" and "name format".
I would like to change destination folder from Session Output Folder to Selects Folder and always keep the original file name.
Any help gratefully appreciated
Thanks in advance
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
on exportOrigRate(trueOrFalsePacked, myRating, subFolderName)
tell front document of application "Capture One 20"
set include adjustments of export original settings to true
set packed of export original settings to trueOrFalsePacked
set listOfVariants to variants whose rating is myRating
set sub folder of export original settings to subFolderName
export originals variants listOfVariants
end tell
end exportOrigRate
tell current document
tell me to exportOrigRate(true, 5, "5STARS")
tell me to exportOrigRate(true, 4, "4STARS")
tell me to exportOrigRate(false, 3, "3STARS")
tell me to exportOrigRate(false, 2, "2STARS")
tell me to exportOrigRate(false, 1, "1STARS")
end tell
-
[Edit: amended below to work]
I got this to work for a catalog but having difficulty with a session. I'm not really acquainted with them. Still, I don't understand why this version of your script doesn't work on the session I created (without tethering, it's true).
The script may look quite a bit different but that's mainly because of my saving and restoring the export original settings, which I think is a good idea generally. Of course, it may not matter to you.
The two specific issues you have re destination folder and file naming are hopefully addressed. Tokens are expressed in square brackets and although the CO AS dictionary says that destination folder is of type text or file, it seems you can also pass an alias.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
-- First it's probably good practice to save the initial export original settings
tell application "Capture One 20"
-- Always be careful accessing front/first document; best to identify your target (document) early on
-- so you know what you're referring to always later on in your script.
-- This is important if you have multiple documents open but seems to make
-- a difference also when manipulating Recipes, for instance, even with just one
-- document open (CO20 at least).
-- Anyway, I wondered if this was the case here, too.
-- I assume you're using a session as you mention Selects folder
set frontDocument to first document whose kind is session --whose kind is session
set selectsFolder to selects of frontDocument
-- debug while testing with a catalog
if selectsFolder is missing value then
-- a folder I know exists on my system for debugging
set selectsFolder to alias "Data:Photography:Test:"
end if
-- save/adjust export original settings
tell export original settings of frontDocument
set savedExportSettings to its properties
set its destination folder to selectsFolder
set its include adjustments to true
set its naming method to text and tokens
-- I think this should give you the right naming. Multiple variants of the same original will be suffixed 1, 2, etc. Tokens are expressed in square brackets.
set its naming format to "[Image Name]"
end tell
end tell
--my exportOrigRate(true, 5, "5STARS")
--my exportOrigRate(true, 4, "4STARS")
--my exportOrigRate(false, 3, "3STARS")
--my exportOrigRate(false, 2, "2STARS")
my exportOrigRate(false, 1, "1STARS", frontDocument)
-- To restore export original settings...
-- It would be nice to simply restore all saved settings from one record
-- but CO complains if you try to restore a value of missing value to any property,
-- even if this is the value you initially retrieved on saving the properties.
-- So we have to restore values individually, testing for missing value along the way
tell application "Capture One 20"
tell export original settings of frontDocument
set its include adjustments to include adjustments of savedExportSettings
set its destination folder to destination folder of savedExportSettings
set its packed to packed of savedExportSettings
if sub folder of savedExportSettings is not missing value then
set its sub folder to sub folder of savedExportSettings
end if
set its naming method to naming method of savedExportSettings
set its naming format to naming format of savedExportSettings
end tell
end tell
on exportOrigRate(trueOrFalsePacked, myRating, subFolderName, theDocument)
local debugProps
tell application "Capture One 20"
tell export original settings of theDocument
set its packed to trueOrFalsePacked
set its sub folder to subFolderName
--set debugProps to its properties
end tell
set listOfVariants to variants of theDocument whose rating is myRating
export originals variants listOfVariants
end tell
end exportOrigRate0 -
My mistake: Substitute this handler for the one above. We're telling our document to export... All seems to work as expected now.
on exportOrigRate(trueOrFalsePacked, myRating, subFolderName, theDocument)
local debugProps
tell application "Capture One 20"
tell theDocument
tell its export original settings
set its packed to trueOrFalsePacked
set its sub folder to subFolderName
set debugProps to its properties
end tell
set listOfVariants to variants whose rating is myRating
export originals variants listOfVariants
end tell
end tell
end exportOrigRate0 -
Hi Quentin,
Thank you for your help!!! I now understand what was wrong(for the naming part, I did not set naming method to text and tokens).
After spending hours to dig your code, I discovered that when the export originals setting UI is default or when I reset the tool, I systematically got an error with this block of code;
-- save/adjust export original settings
tell export original settings of frontDocument
set savedExportSettings to its properties
set its destination folder to selectsFolder
set its include adjustments to true
set its naming method to text and tokens
-- I think this should give you the right naming. Multiple variants of the same original will be suffixed 1, 2, etc. Tokens are expressed in square brackets.
set its naming format to "[Image Name]"
end tell
end tellI suspect that it comes from the session because when I change manually destination on UI (not via your script), I can get the properties but when the location is set to default (Session Output Folder), I can no longer get properties.
I also noticed that the debug block below doesn't do its job, again I think because of the session (no error but when there's no "Selects" folder in the parent folder, the block doesn't check. I do agree with you though, as a good code, this is needed but I doubt we can override application's behaviour).
set selectsFolder to selects of frontDocument
-- debug while testing with a catalog
if selectsFolder is missing value then
-- a folder I know exists on my system for debugging
set selectsFolder to alias "Data:Photography:Test:"
end ifSession keeps history and the selectFolder is selected on UI, it automatically creates the folder in the parent folder and if there's no history, nor "Selects" folder in the parent folder it automatically chooses Session Output Folder until I create manually "Selects" folder or any folder set to selects folder.
I never use the catalog and never had until I tested the script but noticed that on export originals' UI in catalog, the default location doesn't exist so maybe it explains these behaviours?
It works marvellously on my end like below. Thanks again Quentin, I really appreciated your help and learned a lot!!!
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "Capture One 20"
set frontDocument to first document whose kind is session
set selectsFolder to selects of frontDocument
tell export original settings of frontDocument
set its destination folder to selectsFolder
set its include adjustments to true
set its naming method to text and tokens
set its naming format to "[Image Name]"
end tell
end tell
--my exportOrigRate(true, 5, "5STARS")
--my exportOrigRate(true, 4, "4STARS")
--my exportOrigRate(false, 3, "3STARS")
--my exportOrigRate(false, 2, "2STARS")my exportOrigRate(false, 1, "1STARS", frontDocument)
on exportOrigRate(trueOrFalsePacked, myRating, subFolderName, theDocument)
local debugProps
tell application "Capture One 20"
tell theDocument
tell its export original settings
set its packed to trueOrFalsePacked
set its sub folder to subFolderName
set debugProps to its properties
end tell
set listOfVariants to variants whose rating is myRating
export originals variants listOfVariants
end tell
end tell
end exportOrigRate0
投稿コメントは受け付けていません。
コメント
3件のコメント