I’ve written the following script in Applescript in Snow Leopard, and I tried to use it in Mountain Lion, but to no avail (doesn’t work). The script watches a folder for added files, and if the filetype matches, it will scp it to a server.
It runs great, no errors on Snow Leopard. When it’s run in ML it spits back the error (in console):
AppleScript Runner: CPSGetFrontProcess():
This call is deprecated and should not be called anymore.
I’m almost positive this has something to do with the way the script is written. I have tried copying & pasting into a new script in mountain lion, and then saving that. Doesn’t work either.
Here is the code itself, any insight as to what’s going wrong?
on adding folder items to this_folder after receiving the_files
--set login vars
set fileExt to "zip"
set scpIP to "blah"
set scpUser to "blah"
set scpDest to "/home/blah"
set scpPort to "1234"
--repeat on each file that is added to the folder
repeat with each_file in the_files
set filename to name of (info for each_file)
tell application "Finder"
--check extension, if match, scp. else, error.
if name extension of each_file is fileExt then
try
do shell script "scp -p" & scpPort & " " & scpUser & "@" & scpIP & ":" & scpDes
move each_file to trash
end try
end if
end tell
end repeat
end adding folder items to
To get the name of the file you can simply tell Finder
set filename to name of each_file
“Info for” is deprecated
on adding folder items to this_folder after receiving the_files
--set login vars
set fileExt to "zip"
set scpIP to "blah"
set scpUser to "blah"
set scpDest to "/home/blah"
set scpPort to "1234"
--repeat on each file that is added to the folder
repeat with each_file in the_files
tell application "Finder"
set filename to name of each_file
--check extension, if match, scp. else, error.
if name extension of each_file is fileExt then
try
do shell script "scp -p" & scpPort & " " & scpUser & "@" & scpIP & ":" & scpDes
move each_file to trash
end try
end if
end tell
end repeat
end adding folder items to
Great, that fixes the script so that it works, but I’m still getting the same error from console. Here is a screenshot of the three errors I am getting. I am using nearly the exact script that adayzdone posted above.
For some reason, it’s trying to set the front application to Finder? This script still “works”, but if it’s giving me depreciated call errors it’s slowing it down a ton. Any ideas?
It’s also giving me a bit of difficulty with the “do shell script” command - does anyone know if I’m using that incorrectly or something else?
I made the fixes you guys suggested & everything worked well, but the error “AppleScript Runner: CPSGetFrontProcess():” still displays. I did some research, and found this thread: