What am I doing wrong here?

Can someone tell me where I’m going wrong? When I add an item to the folder to test, I get the error “NSArgumentsWrongScriptError” Thanks in advance.

--Wait for file to be added to folder
on adding folder items to this_folder after receiving added_items
--This is the start of the action
--We're going to repeat with all items added to folder
repeat with item_ in added_items
--Call the other application
open application "Custom.app"
--Move the files to the Processed folder when done
duplicate item_ to ":ServerHD2:Processed"
delete item_
end repeat
--Error Handler below
on error the_error
display dialog the_error buttons {"OK"} default button 1 with icon 0 giving up after 30
tell application "Mail"
set theMessage to (make new outgoing message at end of outgoing messages)
set default_address to "somebody@somewhere.com"
set default_content to the_error
set default_subject to "Script has generated errors!!"
tell theMessage
set visible to true
make new to recipient at end of to recipients with properties {address:default_address}
set subject to default_subject
set content to default_content
send theMessage
end tell
end tell
end try
end adding folder items to

One problem area that I notice is this line:

duplicate item_ to ":ServerHD2:Processed"

First, this needs to be directed to the Finder, as does the delete command that follows it. Second, you cannot duplicate a file or folder to a string of text (the path). You need to identify the string as a valid reference by preceding the path with ‘folder’ or ‘alias’. One final note is that the path might not be valid due to the colon at the beginning. To get a valid path to the “Processed” folder, run this, select the folder and then paste the result into the script:

(choose folder) as text

One other troublesome area might be the following line:

open application "Custom.app"

This will likely fail because it is not a valid command. You can tell the Finder to open the application file by providing the full path or you can try to tell the application to launch or activate.

tell app "Finder" to open alias "path:to:Custom.app"
-- or
tell app "Custom.app" to activate

If, after addressing these issues, the problem remains, the error might be related to “Custom.app”.

– Rob

Thanks - I made the changes suggested and commented out the custom app line to test and it works. When I put the custom app line back in, it won’t complie and wants to know where the custom app is. (Similar to an unregistered app in Windows.) So looks like I’ll have to tra ck the person(s) who wrote the custom app.

If you can launch the custom app by double-clicking its icon, the script should be able to launch it with:

tell app "Finder" to open alias "path:to:Custom.app" 

What happens after that is up to the developer of the custom app.

– Rob