I have a script that I want to change from a folder action to a launchd thingy wotsit. The script runs perfectly as a folder action, but when I change it to a launchd action it won’t work. I get the error message “Finder got an error: File 01_006_01C_testfile_9x6.pdf wasn’t found.”
Here are the two scripts, the only difference is the first part of the script.
This one works:
on adding folder items to this_folder after receiving these_items
tell application "Finder"
set the the_new_text to "_LR"
set {tid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "_"}
repeat with oneItem in these_items
set {name:Nm, name extension:Ex} to (info for oneItem)
if Ex is missing value then set Ex to ""
if Ex is not "" then
set Nm to text 1 thru ((count Nm) - (count Ex) - 1) of Nm
set Ex to "." & Ex
end if
set name of oneItem to (Nm & the_new_text & Ex)
set fileName to name of oneItem
set {theGroup, na, wc} to text items of fileName
set chain to text 3 thru -1 of wc
try
if chain = "C" then
set theServer to "/Volumes/Currys|CurrysDigital_LR_PDF/Weeks/"
else if chain = "PCW" then
set theServer to "/Volumes/PCWorld_LR_PDF/WEEKS/"
end if
end try
try
set command to "/bin/mv -f " & (quoted form of (POSIX path of oneItem)) & space & (quoted form of theServer) & "Week" & (text 1 thru 2 of wc) & "/" & theGroup & "*/"
do shell script command
on error
display dialog command
end try
end repeat
set AppleScript's text item delimiters to tid
end tell
end adding folder items to
This one doesn’t
property folder_path : "/Volumes/PDF/HighRes/File_HighRes"
on run
tell application "Finder"
set action_folder to ((POSIX file folder_path) as alias)
set these_items to every item in action_folder
end tell
tell application "Finder"
set the the_new_text to "_LR"
set {tid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "_"}
repeat with oneItem in these_items
set {name:Nm, name extension:Ex} to (info for oneItem)
if Ex is missing value then set Ex to ""
if Ex is not "" then
set Nm to text 1 thru ((count Nm) - (count Ex) - 1) of Nm
set Ex to "." & Ex
end if
set name of oneItem to (Nm & the_new_text & Ex)
set fileName to name of oneItem
set {theGroup, na, wc} to text items of fileName
set chain to text 3 thru -1 of wc
try
if chain = "C" then
set theServer to "/Volumes/Currys|CurrysDigital_LR_PDF/Weeks/"
else if chain = "PCW" then
set theServer to "/Volumes/PCWorld_LR_PDF/WEEKS/"
end if
end try
try
set command to "/bin/mv -f " & (quoted form of (POSIX path of oneItem)) & space & (quoted form of theServer) & "Week" & (text 1 thru 2 of wc) & "/" & theGroup & "*/"
do shell script command
on error
display dialog command
end try
end repeat
set AppleScript's text item delimiters to tid
end tell
end run