• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: duplicate file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: duplicate file


  • Subject: Re: duplicate file
  • From: Yvan KOENIG <email@hidden>
  • Date: Thu, 24 Mar 2016 21:31:04 +0100


Le 24 mars 2016 à 20:45, RJay Hansen <email@hidden> a écrit :

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
set bluePath to get (POSIX path of (path to home folder))
set bluePath to bluePath & "Dropbox/ Blue"
set conniePath to get (POSIX path of (path to home folder))
set conniePath to conniePath & "Dropbox/ Connie"
set greenPath to get (POSIX path of (path to home folder))
set greenPath to greenPath & "Dropbox/ Green"
set orangePath to get (POSIX path of (path to home folder))
set orangePath to orangePath & "Dropbox/ Orange"
set pinkPath to get (POSIX path of (path to home folder))
set pinkPath to pinkPath & "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 file thisItem to thePath
set the last item of fileList to thisItem

end repeat
end tell

Result: error "Finder got an error: AppleEvent handler failed." number -10000

I haven’t been able to figure this one out. Any help is appreciated.

Thanks,
RJay

If I understand well, the instruction
duplicate file thisItem to thePath
try to duplicate the file thisItem to a folder defined by a POSIX path but Finder is so old that it doesn't know to deal with such item.

I would edit the beginning :
tell application "Finder"

--set up paths to the folders
set bluePath to get (POSIX path of (path to home folder))
set bluePath to bluePath & "Dropbox/ Blue"
set conniePath to get (POSIX path of (path to home folder))
set conniePath to conniePath & "Dropbox/ Connie"
set greenPath to get (POSIX path of (path to home folder))
set greenPath to greenPath & "Dropbox/ Green"
set orangePath to get (POSIX path of (path to home folder))
set orangePath to orangePath & "Dropbox/ Orange"
set pinkPath to get (POSIX path of (path to home folder))
set pinkPath to pinkPath & "Dropbox/ Pink"
end tell

as :

# tell application "Finder"

--set up paths to the folders
set p2h to (path to home folder) as text
set bluePath to p2h & "Dropbox: Blue"
set conniePath to p2h & "Dropbox: Connie"
set greenPath to p2h & "Dropbox: Green"
set orangePath to p2h & "Dropbox: Orange"
set pinkPath to p2h & "Dropbox: Pink"

# or even better :

set p2d to ((path to home folder) as text) & "Dropbox:"
set bluePath to p2d & " Blue"
set conniePath to p2d & " Connie"
set greenPath to p2d & " Green"
set orangePath to p2d & " Orange"
set pinkPath to p2d & " Pink"
# end tell

Auxiliary question : Is the space available at the beginning of the folder names really needed or is it a typo ?


Yvan KOENIG running El Capitan 10.11.4 in French (VALLAURIS, France) jeudi 24 mars 2016 21:30:47



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >duplicate file (From: RJay Hansen <email@hidden>)

  • Prev by Date: duplicate file
  • Next by Date: Re: duplicate file
  • Previous by thread: duplicate file
  • Next by thread: Re: duplicate file
  • Index(es):
    • Date
    • Thread