• 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: RJay Hansen <email@hidden>
  • Date: Thu, 24 Mar 2016 16:06:54 -0500

Thanks for the input Ed. Yeah, this is still quite a work in progress. I haven’t got to worrying about the fileList yet. Wanted to get the file copying working first.


On Mar 24, 2016, at 3:38 PM, Stockly, Ed <email@hidden> wrote:

Also I just noticed you need to uncomment the "--else" or pink path will never work

 


From: Los Angeles Times Los Angeles Times <email@hidden>
Date: Thursday, March 24, 2016 at 1:36 PM
To: AppleScript Digest <email@hidden>
Cc: RJay Hansen <email@hidden>
Subject: Re: 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 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



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 theseItemsto (choose file with prompt "select a pdf to upload" with multiple selections allowed)

tell application "Finder"


--set up paths to the folders
setbluePath to get ((path tohome folder))
setbluePath to (bluePathas text) & "Dropbox: Blue"


setconniePath to get ((path tohome folder))
setconniePath to (conniePathas text) & "Dropbox: Connie"
setgreenPath to get ((path tohome folder))
setgreenPath to (greenPathas text) & "Dropbox: Green"
setorangePath to get ((path tohome folder))
setorangePath to (orangePathas text) & "Dropbox: Orange"
setpinkPath to get ((path tohome folder))
setpinkPath to (pinkPathas 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
setthePath to bluePath
else ifitem 1 of theTeam is "Connie" then
setthePath to conniePath
else ifitem 1 of theTeam is "Green" then
setthePath to greenPath
else ifitem 1 of theTeam is "Orange" then
setthePath to orangePath
else ifitem 1 of theTeam is "Pink" then
setthePath to pinkPath
--else
--
return
end if

tell application "Finder"
repeatwith i from 1 to count of theseItems
setthisItem to itemi of theseItems
duplicatethisItem to thePathas alias
setthe end of fileList tothisItem


endrepeat
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

References: 
 >duplicate file (From: RJay Hansen <email@hidden>)
 >Re: duplicate file (From: "Stockly, Ed" <email@hidden>)
 >Re: duplicate file (From: "Stockly, Ed" <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