Applescript and handy automation
Hi Everyone,
Im in the business of processing huge numbers of files for fashion catalogues.
I need to get multiple operators to export images from Capture One and need to automate the processes.
Unfortunately, Phase One are not particularly helpful when it comes to scripting for their application - They say they don't support people trying to use applescript, which i guess is fine. But! to start with, many features are not available to applescript and many of the commands which are outlined in their dictionary simply do not work.
Take for example the make command. This command is used to create new sessions and favorite folders. It doesn't work - at least not in the way it should or any near guess.
This leaves me out in the cold when trying to do something which would make capture one IMMENSELY useful - namely, linking a database to capture one to enable my operators to open preset raw folders and destination folders.
So. I have taken matters into my own hands and decided to make a workaround for creating sessions and adding favorite folders from applescript.
Its a little inelegant but does the trick.
I'd like to take this opportunity to ask phase one to pay more attention to the applescript functionality of capture one. PLEASE PLEASE PLEASE FIX IT.
Anyway, thanks for your time. I hope this helps someone.
Benjamin
Copy and paste the following into script editor or xcode. :
***************************
START CODE HERE
***************************
(*NEW SESSION MAKER for capture one pro
Created by Benjamin Storrier as a workaround for Phase Ones inability to make
Capture One Pro applescript functional - which common sense would say they should do
before telling everyone they don't provide applescript support.
<grumble>
so basically. fruit around with this script.
It basically inserts a posix path (or a number of them) into a session fragment
You can then load this session like any other session.
This is to work around the fact that the make command doesn't do anything. (beside frustrate the hell out of me)
*)
--get the aliases of the folders we want to add - you can do this however you like.
set Alias1 to choose folder without invisibles
set Alias2 to choose folder without invisibles
--the function takes records as parameters so you can make as many folders as you like.
--how you get these aliases into the record is up to you.
set myAliases to {Alias1, Alias2}
--insert the new paths into a capture one session fragment
set sessionFragment to insertPaths(myAliases)
--save the session fragment to a temporary path
set sessionFile to saveFragment(sessionFragment)
--open the session fragment in capture one
tell application \"Capture One PRO\"
launch
open sessionFile
end tell
--*****END MAIN SCRIPT
--our useful handlers
--inserts paths into sesion fragment in a super low tech brute force manner.
--10.4+ has some xml handling stuff in it - you can use that if you want
--I've opted for this method since i need the script to work on multiple pre 10.4 machines.
--You can read a session file to get the idea of how it works. Basically, the output from this function
--is the bare minimum C1 will cope with.
--If you want to set capture and process folders - its pretty easy to work out after looking at a real session.
on insertPaths(myAliases)
--xml. yay.
set crlf to (ASCII character 13) & (ASCII character 10)
set sessionHeader to \"<dict>\" & crlf & \"<key>FavoriteList</key>\" & crlf & \"<array>\" & crlf
set sessionFooter to \"</array>\" & crlf & \"</dict>\" & crlf & \"</plist>\"
set itemHeader to \"<dict>\" & crlf & \"<key>\"
set newKey to \"<key>\"
set endKey to \"</key>\" & crlf & \"<string>\"
set endString to \"</string>\" & crlf
set itemEnd to \"</dict>\" & crlf
--ok. lets initialise the fragment
set sessionFragment to sessionHeader
--add each alias
repeat with anAlias in myAliases
--get the info we want from each alias
tell application \"Finder\"
set aname to name of anAlias
set aPath to POSIX path of anAlias
end tell
--...and put each name and path into the fragment
set sessionFragment to sessionFragment & itemHeader & \"Name\" & endKey & aname & endString & newKey & \"URL\" & endKey & \"file://localhost\" & aPath & endString & itemEnd
end repeat
--polish off the fragment
set sessionFragment to sessionFragment & sessionFooter
--return the fragment
return sessionFragment
end insertPaths
--save the fragment to disk
on saveFragment(sessionFragment)
--lets save the fragment to /tmp
set posixTempFile to \"/tmp/fragment.session\"
set theFile to (POSIX file posixTempFile)
open for access theFile with write permission
--erase the previous fragment
set eof theFile to 0
write (sessionFragment as text) to theFile
close access theFile
return theFile
end saveFragment
Im in the business of processing huge numbers of files for fashion catalogues.
I need to get multiple operators to export images from Capture One and need to automate the processes.
Unfortunately, Phase One are not particularly helpful when it comes to scripting for their application - They say they don't support people trying to use applescript, which i guess is fine. But! to start with, many features are not available to applescript and many of the commands which are outlined in their dictionary simply do not work.
Take for example the make command. This command is used to create new sessions and favorite folders. It doesn't work - at least not in the way it should or any near guess.
This leaves me out in the cold when trying to do something which would make capture one IMMENSELY useful - namely, linking a database to capture one to enable my operators to open preset raw folders and destination folders.
So. I have taken matters into my own hands and decided to make a workaround for creating sessions and adding favorite folders from applescript.
Its a little inelegant but does the trick.
I'd like to take this opportunity to ask phase one to pay more attention to the applescript functionality of capture one. PLEASE PLEASE PLEASE FIX IT.
Anyway, thanks for your time. I hope this helps someone.
Benjamin
Copy and paste the following into script editor or xcode. :
***************************
START CODE HERE
***************************
(*NEW SESSION MAKER for capture one pro
Created by Benjamin Storrier as a workaround for Phase Ones inability to make
Capture One Pro applescript functional - which common sense would say they should do
before telling everyone they don't provide applescript support.
<grumble>
so basically. fruit around with this script.
It basically inserts a posix path (or a number of them) into a session fragment
You can then load this session like any other session.
This is to work around the fact that the make command doesn't do anything. (beside frustrate the hell out of me)
*)
--get the aliases of the folders we want to add - you can do this however you like.
set Alias1 to choose folder without invisibles
set Alias2 to choose folder without invisibles
--the function takes records as parameters so you can make as many folders as you like.
--how you get these aliases into the record is up to you.
set myAliases to {Alias1, Alias2}
--insert the new paths into a capture one session fragment
set sessionFragment to insertPaths(myAliases)
--save the session fragment to a temporary path
set sessionFile to saveFragment(sessionFragment)
--open the session fragment in capture one
tell application \"Capture One PRO\"
launch
open sessionFile
end tell
--*****END MAIN SCRIPT
--our useful handlers
--inserts paths into sesion fragment in a super low tech brute force manner.
--10.4+ has some xml handling stuff in it - you can use that if you want
--I've opted for this method since i need the script to work on multiple pre 10.4 machines.
--You can read a session file to get the idea of how it works. Basically, the output from this function
--is the bare minimum C1 will cope with.
--If you want to set capture and process folders - its pretty easy to work out after looking at a real session.
on insertPaths(myAliases)
--xml. yay.
set crlf to (ASCII character 13) & (ASCII character 10)
set sessionHeader to \"<dict>\" & crlf & \"<key>FavoriteList</key>\" & crlf & \"<array>\" & crlf
set sessionFooter to \"</array>\" & crlf & \"</dict>\" & crlf & \"</plist>\"
set itemHeader to \"<dict>\" & crlf & \"<key>\"
set newKey to \"<key>\"
set endKey to \"</key>\" & crlf & \"<string>\"
set endString to \"</string>\" & crlf
set itemEnd to \"</dict>\" & crlf
--ok. lets initialise the fragment
set sessionFragment to sessionHeader
--add each alias
repeat with anAlias in myAliases
--get the info we want from each alias
tell application \"Finder\"
set aname to name of anAlias
set aPath to POSIX path of anAlias
end tell
--...and put each name and path into the fragment
set sessionFragment to sessionFragment & itemHeader & \"Name\" & endKey & aname & endString & newKey & \"URL\" & endKey & \"file://localhost\" & aPath & endString & itemEnd
end repeat
--polish off the fragment
set sessionFragment to sessionFragment & sessionFooter
--return the fragment
return sessionFragment
end insertPaths
--save the fragment to disk
on saveFragment(sessionFragment)
--lets save the fragment to /tmp
set posixTempFile to \"/tmp/fragment.session\"
set theFile to (POSIX file posixTempFile)
open for access theFile with write permission
--erase the previous fragment
set eof theFile to 0
write (sessionFragment as text) to theFile
close access theFile
return theFile
end saveFragment
0
-
I totally agree with you!
Any software that prides itself in its efficient workflow needs to be extensively scriptable. C1 has always had pretty poor Applescript capabilities and to make things worse, there seems to be a bug in the newer releases that prevents the processing of more than one file through Applescript. Even Phase One's example processing script no longer works.
I know Phase One probably doesn't see this an important issue, but for this reason alone I have had to switch my workflow over to Adobe software. Until the scripting capabilities of C1 are improved I have little use for the software in the majority of my projects.
WF0 -
Hi Everyone.
Sorry
I was tired when I posted.
Here is the rest of the script.
Ill just carry on from the beginning of the line which was truncated.
Cheers
B
*****COPY FROM HERE****
--add each alias
repeat with anAlias in myAliases
--get the info we want from each alias
tell application \"Finder\"
set aname to name of anAlias
set aPath to POSIX path of anAlias
end tell
--...and put each name and path into the fragment
set sessionFragment to sessionFragment & itemHeader & \"Name\" & endKey & aname & endString & newKey & \"URL\" & endKey & \"file://localhost\" & aPath & endString & itemEnd
end repeat
--polish off the fragment
set sessionFragment to sessionFragment & sessionFooter
--return the fragment
return sessionFragment
end insertPaths
--save the fragment to disk
on saveFragment(sessionFragment)
--lets save the fragment to /tmp
set posixTempFile to \"/tmp/fragment.session\"
set theFile to (POSIX file posixTempFile)
open for access theFile with write permission
--erase the previous fragment
set eof theFile to 0
write (sessionFragment as text) to theFile
close access theFile
return theFile
end saveFragment0 -
I'd like to use this approach for creating the Destination Presets. I have particular specs I'd like files to be output by a growing pool of photographers and would like to simplify the process of getting them to all use the same settings. If I could have a script that would create MY destination/output settings that would be amazing. I have some experience with applescript but have a hard time trying to decipher scripts some times... can you point me in the right direction... show me how to get C1 to create a new destination preset?
Thanks.0 -
If I want to modify the resulting name (Fragment) of the session in the script do I simply replace every instance of "fragment" with "new name"? 0 -
Hi There,
I've been working on new scripts for Capture One session management, but Im writing them in ruby instead of applescrtipt. (ruby is the bees knees)
I've been taking the approach of building FULL session files (which are just .plists) and modifying the values so that they are useful to me.
(you can specify output settings, favorite folders, process destinations etc)
I've been a bit busy recently to update them and to be honest, I'll have to hunt around in my mess to find the one that works - but when I find it, I'll post it or a link to it.
If you'd like to email me to prompt me along (I'm forgetful) then feel free.
You can get me on
ben at mondodigital d0t com d0t au0 -
To krdzine1,
Try the script below. Just follow the directions at the top. This script uses UI scripting to create a new process destination using the variable you set in the top of the script.
This forum truncats long messages so here is a link to the script.
Let me know if you have any questions or comments.
Good Luck,
Mark0
Post is closed for comments.
Comments
7 comments