--I’m writing a script that will take user chosen pdf file(s) and upload them to a user chosen Dropbox folder then send an email to the folder’s owner. I’m trying to use the Finder
to copy the file to the Dropbox folder. Here is what I have:
set theseItemsto (choose file
with prompt "select a pdf to upload" with
multiple selections allowed)
tell application "Finder"
--set up paths to the folders (not using posix paths)
set
bluePath to get ((path tohome folder))
set
bluePath to (bluePath astext) & "Dropbox: Blue"
set
conniePath to get ((path tohome folder))
set
conniePath to (conniePath astext) & "Dropbox: Connie"
set
greenPath to get ((path tohome folder))
set
greenPath to (greenPath astext) & "Dropbox: Green"
set
orangePath to get ((path tohome folder))
set
orangePath to (orangePath astext) & "Dropbox: Orange"
set
pinkPath to get ((path tohome folder))
set
pinkPath to (pinkPath astext) & "Dropbox: Pink"
end tell
set fileList to {}
--choose the folder we're going to upload to
choose from list {"Blue", "Connie", "Green", "Orange", "Pink"}
with prompt "Choose the team Dropbox folder"
set theTeam to
result
if item 1 of
theTeam is "Blue" then
setthePath
to bluePath
else if item 1 oftheTeam
is "Connie" then
setthePath
to conniePath
else if item 1 oftheTeam
is "Green" then
setthePath
to greenPath
else if item 1 oftheTeam
is "Orange" then
setthePath
to orangePath
else if item 1 oftheTeam
is "Pink" then
setthePath
to pinkPath
--else
--
return
end if
tell application "Finder"
repeat withi
from 1 to count of
theseItems
setthisItem
to itemi
of theseItems
duplicatethisItemtothePathas
alias—
— the duplicate command referrred to file thisItem by thisItem was an alias
— also thePath was not resolving. I find it easier to use aliases and text specifiers than posix paths
set theend
of fileList to
thisItem
—this wasn't working because there was no items in fileList, so no last item.
—I'm guessing you wanted to set the end of fileList, so you'll have a list of moved files
end repeat
end tell
--Result: error "Finder got an error: AppleEvent handler failed." number -10000