--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 theseItems
to (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 to
home folder))
set
bluePath to (bluePath as
text) & "Dropbox: Blue"
set
conniePath to get ((path to
home folder))
set
conniePath to (conniePath as
text) & "Dropbox: Connie"
set
greenPath to get ((path to
home folder))
set
greenPath to (greenPath as
text) & "Dropbox: Green"
set
orangePath to get ((path to
home folder))
set
orangePath to (orangePath as
text) & "Dropbox: Orange"
set
pinkPath to get ((path to
home folder))
set
pinkPath to (pinkPath as
text) & "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
set
thePath to bluePath
else if item 1 of
theTeam is "Connie" then
set
thePath to conniePath
else if item 1 of
theTeam is "Green" then
set
thePath to greenPath
else if item 1 of
theTeam is "Orange" then
set
thePath to orangePath
else if item 1 of
theTeam is "Pink" then
set
thePath to pinkPath
--else
--
return
end if
tell application "Finder"
repeat with
i from 1 to
count of theseItems
set
thisItem to item
i of theseItems
duplicate
thisItem
to
thePath
as 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 the
end 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