• 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: Help needed with Finder copy/duplicate with Apple script !!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help needed with Finder copy/duplicate with Apple script !!


  • Subject: Re: Help needed with Finder copy/duplicate with Apple script !!
  • From: Ron Hunsinger <email@hidden>
  • Date: Thu, 12 May 2011 11:14:09 -0700

On May 12, 2011, at 10:19 AM, Naresh Kongara wrote:
I want to copy an item say on desktop to temporary folder.

set sourceFile to "/Users/nareshkongara/Desktop/Saharsh.jpg"
set targetDirectory to "/var/folders/+S/+SfqdTOqEDapIOVh4OYDIE+++TI/-Tmp-/"

tell application "Finder"
duplicate sourceFile to targetDirectory
end tell

Besides using POSIX paths where Finder expects HFS-style paths, you're trying to duplicate one string to another. Finder won't interpret a string as a file/folder unless you tell it to. That is, if sourceFile and targetDirectory are strings (in the right format), you should be saying:

duplicate file sourceFile to folder targetDirectory

But you don't need to mess with paths at all. Finder knows all about files and folders.

tell application "Finder"
set sourceFile to file "Saharsh.jpg" of desktop
set targetDirectory to path to temporary items folder
-- set targetDirectory to parent of targetDirectory
duplicate sourceFile to targetDirectory
end tell

(I notice you're moving the file to the parent of the temporary items folder. On your machine, the temporary items folder would be one level deeper, at the POSIX path "/var/folders/+S/+SfqdTOqEDapIOVh4OYDIE+++TI/-Tmp-/TemporaryItems". If you really want to move directly to .../-Tmp-/, uncomment the commented line.)
 _______________________________________________
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: 
 >Help needed with Finder copy/duplicate with Apple script !! (From: Naresh Kongara <email@hidden>)

  • Prev by Date: Re: Help needed with Finder copy/duplicate with Apple script !!
  • Next by Date: Re: Help needed with Finder copy/duplicate with Apple script !!
  • Previous by thread: Re: Help needed with Finder copy/duplicate with Apple script !!
  • Next by thread: Re: Help needed with Finder copy/duplicate with Apple script !!
  • Index(es):
    • Date
    • Thread