• 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: "Stockly, Ed" <email@hidden>
  • Date: Thu, 24 Mar 2016 20:36:30 +0000
  • Thread-topic: duplicate file

Of course, Yvan beat me too it, but this version works for me

 --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




From: <applescript-users-bounces+ed.stockly=email@hidden> on behalf of RJay Hansen <email@hidden>
Date: Thursday, March 24, 2016 at 12:45 PM
To: AppleScript Digest <email@hidden>
Subject: duplicate file

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:
 --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 ((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

set the end of fileList to thisItem

end repeat

end tell


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


 _______________________________________________
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

  • Follow-Ups:
    • Re: duplicate file
      • From: "Stockly, Ed" <email@hidden>
References: 
 >duplicate file (From: RJay Hansen <email@hidden>)

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