Applescript: Was image processed? Current session?
Just trying to confirm the obvious here . . .
I'm writing a script which will help extract favored images out of my photographer's workflow. There are two indicators which happen organically. (1) An image was tagged or (2) the image was processed (especially if it was processed as high res).
Even though the C1Pro interface displays both tag and processed state, it appears that its Applescript dictionary has no access to whether it was processed. To get access to that, I have to parse the RAW file's plist. Right?
Also, my plan in the script was to open the session through the Finder. I also wanted to write scripts which could be run against an already open session. Forgive me for being dumb on this. I know how to address a session I have opened via Applescript. But, I can't figure out how to address the open session. "Tell current session" or "tell frontmost session" don't work. "Tell session 1" addresses the first session in the session list.
Thanks!
Gary
I'm writing a script which will help extract favored images out of my photographer's workflow. There are two indicators which happen organically. (1) An image was tagged or (2) the image was processed (especially if it was processed as high res).
Even though the C1Pro interface displays both tag and processed state, it appears that its Applescript dictionary has no access to whether it was processed. To get access to that, I have to parse the RAW file's plist. Right?
Also, my plan in the script was to open the session through the Finder. I also wanted to write scripts which could be run against an already open session. Forgive me for being dumb on this. I know how to address a session I have opened via Applescript. But, I can't figure out how to address the open session. "Tell current session" or "tell frontmost session" don't work. "Tell session 1" addresses the first session in the session list.
Thanks!
Gary
0
-
Hi There, Applescript dictionary has no access to whether it was processed. To get access to that, I have to parse the RAW file's plist. Right?
The processed state doesn't seem to be in the RAW plist. Please post a solution if you figure one out.
You can test for the tag but it is read only.
-- Process image files
tell application "Capture One PRO"
repeat with myImage in myImages
if tag of myImage is nine then
start processing myImage target myTarget
end if
end repeat
end tell
To change the tag you have to write to the plist for that image.
-- Tag ordered images to 9
repeat with i in fullImagePlist
if i is in orderedImageNames then
do shell script "defaults write " & (quoted form of POSIX path of (settingsPath & i)) & " Tagged -int 9"
end if
end repeat
These code snips have some variables ( i.e. fullImagePlist, settingsPath which are HFS style paths like iMac HD:Users:marktorrance:Pictures:Capture One Default Session ) that are created elsewhere in a larger script so these won't function. I could give you the larger script if you want to mess with it. You would have to change a few lines to suit your set up. This particular script is triggered by an incoming email from our web server. The message triggers a rule in mail that triggers an applescript that:
reads the email
extracts a list of images that a client ordered
extracts the size and format
opens the job in C1 Pro
Tags & Processes the images
The email is from an online form so it's structure is controlled. So what this basically does is automatically process images ordered from our client area. If I'm in another shoot or out of the studio the images will get processed and be ready for me to go through. C1 does lack in the applescript department but I have been able to more then I first thought would be possible.
This example shows how to read the contents of the ImageSettings folder containing the plist files.
Change the first two lines of code to match your system.
--The path to the Default Session
set folderPath to "iMac HD:Users:YOURUSERNAME:Pictures:Capture One Default Session:"
--The path to the session file, make sure you have the correct session name
set sessionPath to (folderPath & "Default.session")
--The path to the Captures folder
set capturesPath to (folderPath & "Captures:")
--The path to the ImageSettings folder
set settingsPath to (folderPath & "Captures:Capture One Settings:ImageSettings:")
--Get names of all plist files in current job and remove .plist from name
tell application "Finder"
set fullImagePlist to the name of every file in the folder (settingsPath) as list
end tell
return fullImagePlist
You could of course use a prompt so the user can pick a session folder then get the name of the ".session" file in that folder. Or prompt the user to select a session file and open it with finder which would do the same as double clicking a session file which is to open C1 and load that session. Here is an example
set mySessionFile to choose file with prompt "Select a Session File \\".session\\""
tell application "Finder"
open mySessionFile
end tell
Hear are some scripts I wrote that you might find handy.
This one helps manage your session menu.
And This one creates scripts that will create predefined process destinations.
Good Luck,
Mark0 -
[quote="mtorrance" wrote:
Hi There,Applescript dictionary has no access to whether it was processed. To get access to that, I have to parse the RAW file's plist. Right?
The processed state doesn't seem to be in the RAW plist. Please post a solution if you figure one out.
When I look at the /session folder/Captures/Capture One Settings/ImageSettings/imagename.plist file I see a section like:
<key>ProcessedList</key>
<array>
<dict>
<key>ProcessedDate</key>
<string>2008-04-26 06:39:57 -0700</string>
<key>ProcessedURL</key>
<string>file://[path to processed file]</string>
</dict>
</array>
I don't know enough about regular expressions to provide code to ID this. But, this looks like it tells C1Pro when an image was processed and where. When I look at the same file for an image I haven't processed <key>ProcessedList</key> isn't there.
Thanks for sharing your experience scripting c1pro. I'm sure all the code will come in handy.0 -
Right you are! I'm glad you caught that. When I looked the first time at the plist for a particular image, which had a processed badge on it, the processedList array wasn't there. I must have looked at the file before it wrote to it. At any rate now you can read the array or just check for it's existence. The following script will prompt you to select a session folder then tag any images that have been processed with the green check mark badge. You could go further and read the contents of each processed entry which contains the processed date and the file url to the processed image. If you only need to check if an image has been processed then just checking to see if "ProcessedList" exists in the plist is enough.
Also you'll find the following links useful.
--The path to the Default Session
set folderPath to choose folder with prompt "Select a Session Folder \\"A folder that contains a .session file\\""
--Get name of the session file
tell application "Finder"
set sessionFile to (get name of every file of folder ((folderPath) as string) whose name ends with "session")
set sessionFile to first item of sessionFile as string
end tell
--The path to the session file
set sessionPath to (folderPath & sessionFile) as string
--The path to the Captures folder
set capturesPath to (folderPath & "Captures:") as string
--The path to the ImageSettings folder
set settingsPath to (folderPath & "Captures:Capture One Settings:ImageSettings:") as string
--Get names of all image plist files for the current session
tell application "Finder"
set fullImagePlist to the name of every file in the folder (settingsPath) as list
end tell
-- This section steps through every plist file for the selected session and tags the ones that have been processed
tell application "Finder"
repeat with i from 1 to count of fullImagePlist
try -- escapes the instance that the plist has no ProcessedList because the image has never been processed
tell application "System Events"
-- Read the value of Processedlist for the current image
tell property list file (settingsPath & (item i of fullImagePlist))
tell contents
value of property list item "ProcessedList"
-- if ProcessedList is not empty then tag the image with a check mark "70"
if result is not "" then
--If the image has been processed tag it with the checkmark badge
tell application "System Events"
tell property list file (settingsPath & (item i of fullImagePlist))
tell contents
set value of property list item "Tagged" to "70"
end tell
end tell
end tell
end if
end tell
end tell
end tell
end try
end repeat
end tell
Additionally I have code in my script that will remove any orphaned plist files by comparing the file names against the images in the Captures folder. Sometimes when renaming images some plist files get left behind with old names.
I've been wanting to write a script that will reset the processed state and now it looks as though that may be possible. We always process proofs for the web so every image in a job shows it's been processed but I really only want processed badges on the images processed after that for HiRes.
Also a note on dealing with tagging via the plist. Setting "Tagged" to "0" (zero) is no tag, 1-9 will tag it with that number, "70" Yes, "60" Maybe, "50" No.0 -
Here is a script that will reset the processed state of an image. This removes the ProcessedList key from the plist file for every image in the selected session. If the ProcessedList exists, even if it's empty, C1 will place a processed badge on an image.
--Set default for text item delimiters
set AppleScript's text item delimiters to ""
set ASTID to AppleScript's text item delimiters
--The path to the Default Session
set folderPath to choose folder with prompt "Select a Session Folder \\"A folder that contains a .session file\\""
--Get name of the session file
tell application "Finder"
set sessionFile to (get name of every file of folder ((folderPath) as string) whose name ends with "session")
set sessionFile to first item of sessionFile as string
end tell
--The path to the session file
set sessionPath to (folderPath & sessionFile) as string
--The path to the Captures folder
set capturesPath to (folderPath & "Captures:") as string
--The path to the ImageSettings folder
set settingsPath to (folderPath & "Captures:Capture One Settings:ImageSettings:") as string
--Get names of all plist files in current job and remove .plist from name
tell application "Finder"
set fullImagePlist to the name of every file in the folder (settingsPath) as list
repeat with i from 1 to count of fullImagePlist
set AppleScript's text item delimiters to ".plist"
set item i of fullImagePlist to text item 1 of item i of fullImagePlist
set AppleScript's text item delimiters to ASTID
end repeat
end tell
-- This section steps through every plist file for the selected session and tags the ones that have been processed
tell application "Finder"
repeat with i from 1 to count of fullImagePlist
try -- escapes the instance that the plist has no ProcessedList because the image has never been processed
tell application "System Events"
-- Read the value of Processedlist for the current image
tell property list file (settingsPath & (item i of fullImagePlist) & ".plist")
tell contents
value of property list item "ProcessedList"
-- if ProcessedList exists then delete it
if result is not "" then
do shell script "defaults delete " & (quoted form of POSIX path of myPath) & " ProcessedList"
end if
end tell
end tell
end tell
end try
end repeat
end tell
While this is not exactly what you're looking for you can place other code after ( if result is not "" then ) which will manipulate the plist file for that image if it has been processed. Or create a second list of the images as well then check the plist for each image and if it has been processed or tagged move the image and it's plist to a new location. You could also tag the processed images as in the previous script then script C1 to move the images that are tagged. By having C1 move the files the plist files should get moved as well. If you move the images via Finder you'll have to move the plist files also to maintain the image settings.
Also, since C1 is somewhat limited in the Applescript area I frequent a Applescript Forum that is very helpful.
MacScripter
Good Luck,
Mark0 -
Your excellent post mentioned that your script will "select a session folder then tag any images that have been processed with the green check mark badge."
Is there an AppleScript that will do the opposite: Process all Tagged images in a Session?
I would want both Green Check Marks and Number "1" tags to be processed. I realize this is a slightly different objective, but your script sounds somewhat close... I'm going to try to figure it out, but I don't know AppleScript, at least not yet 😊
I use C1Pro 3.7.8 on Mac OS 10.5.3.
Thank so much!!
-Michael[quote="mtorrance" wrote:
Right you are! I'm glad you caught that. When I looked the first time at the plist for a particular image, which had a processed badge on it, the processedList array wasn't there. I must have looked at the file before it wrote to it. At any rate now you can read the array or just check for it's existence. The following script will prompt you to select a session folder then tag any images that have been processed with the green check mark badge. You could go further and read the contents of each processed entry which contains the processed date and the file url to the processed image. If you only need to check if an image has been processed then just checking to see if "ProcessedList" exists in the plist is enough.
Also you'll find the following links useful.
--The path to the Default Session
set folderPath to choose folder with prompt "Select a Session Folder \"A folder that contains a .session file\""
--Get name of the session file
tell application "Finder"
set sessionFile to (get name of every file of folder ((folderPath) as string) whose name ends with "session")
set sessionFile to first item of sessionFile as string
end tell
--The path to the session file
set sessionPath to (folderPath & sessionFile) as string
--The path to the Captures folder
set capturesPath to (folderPath & "Captures:") as string
--The path to the ImageSettings folder
set settingsPath to (folderPath & "Captures:Capture One Settings:ImageSettings:") as string
--Get names of all image plist files for the current session
tell application "Finder"
set fullImagePlist to the name of every file in the folder (settingsPath) as list
end tell
-- This section steps through every plist file for the selected session and tags the ones that have been processed
tell application "Finder"
repeat with i from 1 to count of fullImagePlist
try -- escapes the instance that the plist has no ProcessedList because the image has never been processed
tell application "System Events"
-- Read the value of Processedlist for the current image
tell property list file (settingsPath & (item i of fullImagePlist))
tell contents
value of property list item "ProcessedList"
-- if ProcessedList is not empty then tag the image with a check mark "70"
if result is not "" then
--If the image has been processed tag it with the checkmark badge
tell application "System Events"
tell property list file (settingsPath & (item i of fullImagePlist))
tell contents
set value of property list item "Tagged" to "70"
end tell
end tell
end tell
end if
end tell
end tell
end tell
end try
end repeat
end tell
Additionally I have code in my script that will remove any orphaned plist files by comparing the file names against the images in the Captures folder. Sometimes when renaming images some plist files get left behind with old names.
I've been wanting to write a script that will reset the processed state and now it looks as though that may be possible. We always process proofs for the web so every image in a job shows it's been processed but I really only want processed badges on the images processed after that for HiRes.
Also a note on dealing with tagging via the plist. Setting "Tagged" to "0" (zero) is no tag, 1-9 will tag it with that number, "70" Yes, "60" Maybe, "50" No.0 -
Hi Getzinger,
This should work for you. Took a couple of hours to whip it up and test it. This script will:
• Prompt user to select a session folder.
• Prompt user to select the tag(s) to process.
• Prompt user to select the process destination to use (list gathered from the preference file)
The script is too long to put in the post, it keeps clipping it. Below is a link to download it.
http://www.bwstudios.biz/downloads/Proc ... Images.zip
Enjoy,
Mark0
投稿コメントは受け付けていません。
コメント
6件のコメント