Folks,
I’ve written a folder action to address a production process in our workflow. We scan slides via a Mac running 10.3.9 and then want to have the files copied over to our Linux server. I developed and tested a script under my 10.4.3 system that works. When a new file is put in a folder, the script is to check and see if the comment field of the folder contains a value (the Unix path of the destination folder) and use that as the destination location. If there is no value then it prompt for a destination folder to use (and stores the value in the current folder’s comment field).
--on adding folder items to this_folder after receiving these_items
on adding folder items to projectFolder after receiving scannedImageFiles
-- Initialize variables
set scannedImageFileCount to count of scannedImageFiles
set copyCount to 0
set errorCount to 0
set errorMessage to ""
tell application "Finder"
set projectName to name of projectFolder
-- Check to see if an output directory was already specified.
if ((comment of projectFolder) = "") then
-- Choose the destination folder for the project files.
set destinationFolder to choose folder with prompt "Choose the project folder on Pogo where the " & projectName & " scanned images should go:"
set outputDirectory to POSIX path of destinationFolder
set outputText to outputDirectory as string
set (comment of projectFolder) to outputText
else
try
set destinationDir to (comment of projectFolder) as string
set destinationFolder to (POSIX file destinationDir) as alias
on error
set errorMessage to errorMessage & "ERROR: Unable to read directory comment field." & return
set errorCount to errorCount + 1
end try
end if
end tell
-- For each file in this project folder do the following...
repeat with imageFile in scannedImageFiles
tell application "Finder"
set imageName to name of imageFile
end tell
-- Copy the file to the server location.
tell application "Finder"
try
duplicate imageFile to destinationFolder replacing yes
set copyCount to copyCount + 1
on error
set errorMessage to errorMessage & "ERROR: Unable to copy " & imageName & " to " & outputDirectory & return
set errorCount to errorCount + 1
end try
end tell
end repeat
-- Display the results of the folder action.
--set resultsMessage to "" & scannedImageFileCount & " items found in the " & projectName & " folder." & return
--set resultsMessage to resultsMessage & copyCount & " files successfully copied to " & outputDirectory & " folder." & return
if (errorCount ≠0) then
set resultsMessage to resultsMessage & "There were " & errorCount & " errors:" & return
set resultsMessage to resultsMessage & errorMessage
display dialog resultsMessage buttons {"OK"} default button 1
end if
end adding folder items to
As I mentioned, it works in 10.4.3. It doesn’t copy items to the destination folder in 10.3.9, but it’s not generating an error. Any suggestions on what I should look at modifying to get this to work on the older OS. We can’t upgrade that OS version at this time because the scanner hardware cannot work with 10.4
Thanks in advance,
Jack