Folder Actions playing rough in Leopard ?
Folder Actions playing rough in Leopard ?
- Subject: Folder Actions playing rough in Leopard ?
- From: Jay Louvion <email@hidden>
- Date: Wed, 10 Dec 2008 11:54:15 +0100
- Thread-topic: Folder Actions playing rough in Leopard ?
Title: Folder Actions playing rough in Leopard ?
I have been a user of Applescript, in particular folder action scripts allowing my workflow to be automated in a wonderful way (my business is in photography) and after having migrated to Leopard, I have started noting that for some reason, folder action scripts that previously worked fine together have started “interrupting” one another.
In one particular case, I have one FAS attached to /Volumes/ that is in charge of copying images from a compact flash card that don’t have a locked status. When they are copied to another folder who’s job it is to open them up automatically in a viewing program, the copying stops.
I use 24U osax in order to monitor the advance of the copy, since it’s a repeat step and not a global one, in order to copy and then lock the files on the card once the copy has been done with success.
I join the two scripts hereunder and look forward to all of your feedback.
--------------
[script to copy the files]
property processname : "Processing files"
property ProgressMessage1 : "Copy of "
property ProgressMessage2 : " files in progress"
property ExtraProgressInfo : "(read a book if you're bored)"
property ExtensionList : {"jpg", "NEF", "TIF"}
property DestFolderName : "PhotoIn:"
to sort_items of main_list by sort_list
script o
property l : main_list
property s : sort_list
end script
repeat with i from 2 to count o's l
set v to o's s's item i
set w to o's l's item i
repeat with i from i to 2 by -1
set j to i - 1
tell o's s's item j to if v < it then
set o's s's item i to it
set o's l's item i to o's l's item j
else
set o's s's item i to v
set o's l's item i to w
exit repeat
end if
end repeat
if i is 2 and v < o's s's item 1 then
set o's s's item 1 to v
set o's l's item 1 to w
end if
end repeat
end sort_items
on adding folder items to this_folder after receiving OneItem
set destFolder to (path to home folder as text) & DestFolderName as alias
try
try
set source_folder to OneItem as alias
end try
tell application "Finder" to set DCIMwatch to name of every folder of folder source_folder
if the DCIMwatch contains "DCIM" then
tell application "Finder" to set TheContents to (every file of entire contents of folder "DCIM" of source_folder whose name extension is in ExtensionList and locked is false)
set MonitorLength to length of TheContents
if TheContents is {} then
display dialog "No images need copying from the current CF card." & return & "Eject ?" with icon 2 giving up after 30
tell application "Finder" to eject (name of source_folder)
else
set contentlength to (length of TheContents as integer)
set ProgressBar to create progress indicator with properties {global window:true, name:processname, closeable:true, indeterminate progress:false, minimum value:0, maximum value:contentlength, top message:ProgressMessage1 & contentlength & ProgressMessage2, bottom message:ExtraProgressInfo}
set CurVal to 0
DoThatThing(destFolder, source_folder, ProgressBar, CurVal)
activate
delay 1
close progress indicator ProgressBar
tell application "Finder" to eject (name of source_folder)
end if
end if
on error mistake number nmr
if nmr is not -128 then
if mistake does not contain "wasn't not found" then
if mistake does not contain "source_folder" then
if nmr is -15267 then
display dialog "File already exists." with icon 2
else
display dialog mistake & return & nmr
end if
end if
end if
end if
end try
end adding folder items to
on DoThatThing(destFolder, source_folder, ProgressBar, CurVal)
tell application "Finder"
if ((exists of folder "PhotoTemp" of container of destFolder) is false) then
set TempFolder to make new folder at container of destFolder with properties {name:"PhotoTemp"}
else
set TempFolder to folder "PhotoTemp" of container of destFolder
end if
end tell
tell application "Finder" to set {file_list, mod_date} to {it, modification date} of (files of folder ¬
source_folder's entire contents whose name extension is in ExtensionList and locked is false) --as alias
sort_items of file_list by mod_date
repeat with oneFile in file_list
update progress indicator ProgressBar current value CurVal
set oneFile to oneFile as alias
tell application "Finder"
set FinalFile to (duplicate oneFile to TempFolder)
try
move FinalFile to destFolder
set locked of oneFile to true
on error mistake number nmr
activate
display dialog mistake & return & nmr
end try
end tell
set CurVal to (CurVal + 1)
end repeat
tell application "Finder" to move TempFolder to trash
end DoThatThing
[/script]
-------------
[script to open the files added]
on adding folder items to this_folder after receiving added_items
try
tell application "iView MediaPro"
open the added_items
--activate
end tell
end try
end adding folder items to
[/script]
Best,
j.
Jay Louvion
Studio Casagrande
3, rue Müller-Brun
1208 Geneva
T+4122 840 3272
F+4122 840 3271
www.studiocasagrande.com
P Please consider the environment before printing this email.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden