• 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: Nigel Garvey <email@hidden>
  • Date: Fri, 25 Mar 2016 00:16:52 +0000

RJay Hansen wrote on Thu, 24 Mar 2016 14:45:30 -0500:

>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

Hi.

Yvan and Ed have already pointed out that the Finder doesn't take POSIX
paths and you can't set a non-existent list item to anything.

On the face of it, the code could essentially be reduced to this:

  set theseItems to (choose file of type "pdf" with prompt "select a pdf to upload" with multiple selections allowed)

  set theTeam to (choose from list {"Blue", "Connie", "Green", "Orange", "Pink"} with prompt "Choose the team Dropbox folder")
  if (theTeam is false) then error number -128
  set theTeam to item 1 of theTeam

  -- set fileList to items of theseItems -- Effect of original code.
  tell application "Finder"
    set teamFolder to folder ("Dropbox: " & theTeam) of home -- Leading space in folder name?
    set duplicatedFiles to (duplicate theseItems to teamFolder)
  end tell


NG


 _______________________________________________
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


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