I have a small script which changes the desktop picture using the pictures in a specific folder. The script uses properties to keep track of the used pictures.
I would like to create a “folder action” script to attach to the picture folder to recompile the picture changing script every time I add or remove pictures from it so that future running will find the new pictures and NOT look for any pictures which I removed. Wha!
My question is using AS 1.3 on OS 8.6 is there a command which will compile the picture running script ?
You don’t need to recompile, you need to reset the properties. You should have a property that includes all the files in your source folder (or perhaps the modification date of the folder). On run, check to see if the files in the source folder match this property (or the mod date), if so, continue as normal, if not, reset the used file property. Probably not as clear as it could be but hopefully it will give you a place to start.
You could combine Jon’s good advice with your own initial impulse by putting folder action handlers in your main script and attaching that to the picture folder. Folder actions don’t have to be separate files. Having them in the same script as the properties they’re supposed to change makes things very much easier.
Thanks for the suggestions !
Since the script which sets the pictures is fairly complex I decided to keep it separate trom the “folder action” script.
I followed jonn8’s advice and simply reset the necessary properties in the script which contains the pictures.
on adding folder items to this_folder after receiving added_items
set theScript to "Paul:Utilities:Apple Script:Scripts (In Use):Change Desktop Picture"
set secondScript to load script theScript
set secondScript's usedp to {}
set secondScript's availablep to {}
store script secondScript in "Paul:Utilities:Apple Script:Scripts (In Use):Change Desktop Picture" with replacing
end adding folder items to
on removing folder items from this_folder after losing these_items
set theScript to "Paul:Utilities:Apple Script:Scripts (In Use):Change Desktop Picture"
set secondScript to load script theScript
set secondScript's usedp to {}
set secondScript's availablep to {}
store script secondScript in "Paul:Utilities:Apple Script:Scripts (In Use):Change Desktop Picture" with replacing
end removing folder items from
Using the above as a “folder action” script on the folder that contains the picture files works just fine .