Fix a cobbled together Folder Action?

Hi,

I’ve been trying to cobble together a Folder Action script, using pieces of Apple supplied scripts … but … surprise surprise, I can’t get it to work. Although, it does at least complile!! :slight_smile:

I’m a photographer and I use a piece of software which doesn’t embed a colorsync profile, so what I want, is files which are sent to a specific folder in the Finder, to be ‘matched’ (converted from) one profile to another … or if they already have a profile, then to be left alone, if it’s the right one, or converted to the right one if it’s not.

To this end I have canibalised the Colorsync scripts (installed with every MacOS install these days), but as I said, it doesn’t work. Could anyone show me where I’m going wrong?

(FWIW, this is quite typical of the dissapointment of Automator, which I have to say, I expected. There is a Colorsync ‘action’ but it is only capable of ‘enbedding’ a profile, not of converting from one to another. So the whole beauty and simplicity and promise of Automator falls apart. Suddenly I need to be an Applescript programmer to make my workflow. :frowning: )

Many thanks for any help.

Grant

This is what I have so far :

on adding folder items to this_folder after receiving these_items
try
repeat with i from 1 to number of items in these_items
set thisFile to item i of these_items
tell application “ColorSyncScripting”
set openImage to open thisFile
set profCount to count of every profile of openImage
end tell
if profCount is 0 then
tell application “ColorSyncScripting”
set sourceProf to profile “Adobe RGB (1998) Profile”
set destProf to profile “sRGB Profile”
match thisFile from source sourceProf to destination destProf
end tell
end if
if profCount is 1 and profName is not “Adobe RGB (1998) Profile” then
tell application “ColorSyncScripting”
set sourceProf to (profile 1 of currImage)
match thisFile from source sourceProf to destination destProf
end tell
end if
end repeat
end try
end adding folder items to

Hi Jacques,

it’s very kind of you to help. Thank you. :slight_smile:

Sadly … the script you’ve made doesn’t do anything at all. It doesn’t work whether there is already a profile in the image or not. Maybe I’ve not configured Folder Actions correctly … but … I think I have. When I ‘Configure’ the Actions for the folder it shows the script as ‘checked’.

Grant

Hi Jacques,

thanks for the reply. :slight_smile:

I’ve verified that the Folder Actions are working properly by using one of the installed scripts (“add - new item alert.scpt”) which I found in the folder you mentioned. It works fine, but I’m afraid the script you helped me with still does not work at all. Nothing happens. I’ve tried with a profile already ‘embedded’ (‘assigned’) and without a profile and it makes no difference. Nothing happens. OTOH, as you said, the installed Colorsync scripts all work fine. It’s just a question of getting them to work as Folder Actions, without any user interaction! Ha!

Grant

Hi Jacques!

Hey! It works! :slight_smile:

Fantastic … this will save me all sorts of time through errors. (The problem I have is that I work with an old Classic app. and it doesn’t embed profiles when it ‘builds’ (renders) an image.

However I still have a problem with the script. :confused:

My app (French app. BTW, called Live Picture) can take anywhere from 5 seconds to 30 minutes to build (render) a file, depending on the complexity of the edits. But the file is available in the Finder instantly … it’s just not ‘whole’. So … the Folder Action runs as soon as it sees the file, but it doesn’t work, because the file isn’t ‘ready’ or ‘finished’ yet. (Obvioiusly the script is working when I just drag a file into the folder).

Is there a way to use a ‘Try’ statement or a ‘Wait’ or even an ‘If’ with a loop, to force the script to run when the file is complete (it is built in blocks)? I’ve noticed that in the ‘Info’ panel in Column View, the image ‘Dimensions’ are “–” (2 dashes) until the file is finally built. Perhaps this could be used?

Many thanks again,

Grant

Hi Jacques,

thanks for the reply. :slight_smile:

No luck though. The profile is not emebedded in the file. I tried changing the delay to 60 seconds, but still no luck.

I wonder if it might be possible to use the ‘Dimensions’ from the File Info? I noticed that Dimensions are at “–” until the file is finally and fully built (rendered). What do you think?

Grant

Hi Jacques,

Success!! :smiley: Many thanks again for all your help. :slight_smile:

The ‘dimensions’ version didn’t work. It seems that it prevents the script from running too soon, as desired, but, it nevertheless runs before the file is fully built and so, the file is damaged (not fully built).

The ‘size check’ script worked straight off … but … only on small build files. So I experimented a bit (slow process for big builds which can take 20-30mins each) and I’ve found that changing the ‘Delay’ to 100 works! (For this Mac anyway … is the delay in seconds or something else? It might need to be altered if it’s processor cycles or something). I don’t know if altering the ‘delay’ is the best way to make it work … but it’s all I could think of.

Without wanting to abuse your kindness/generosity tooo much … could I ask for one last tip to enable me to include this script more fully in my workflow?

Can I include this script in an Automator workflow? For example, it would be useful to be able to run this script, then once it’s finished, have another script take the resultant files and copy them into a folder in iPhoto. I’ve tried including this script in an Automator workflow … but I can’t get the Automator Workflow to run when items are added to the folder. Is it impossible to have an Automator Action run as a Folder Action?

Grant

Hi Jacques,

thanks for the further info … and once again … thanks for the help! :slight_smile:

Grant