• 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: Why is copying a file so hard? part 3
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is copying a file so hard? part 3


  • Subject: Re: Why is copying a file so hard? part 3
  • From: "J. Stewart" <email@hidden>
  • Date: Wed, 22 Jun 2005 05:02:25 -0400

On 06/22/05 at +1000 email@hidden said this

>OK I've tried that with no success
>set the_error to ""
>set foo to "/Users/andrew/Desktop/fish_letter.doc"
>set source to POSIX file foo as alias
>set foo2 to "/Users/andrew/Desktop/fish_letter copy.doc"
>set dest to POSIX file foo2 as alias
>tell application "Finder"
>   try
>       duplicate source to dest with replacing
>   on error errMessage
>       set the_error to the_error & " copying " & foo & "
>failed - " & errMessage
>   end try
>end tell
>
>The error I get is
>Can't make file "Tiger:Users:andrew:Desktop:fish_letter copy.doc"
>into type alias.

1) Does this file exist prior to your attempt to make an alias to it? If the answer is no then that would explain your error, making an alias to a non-existant object isn't possible in AppleScript.

2) The Finder's "duplicate" command takes a location as it's destination parameter. You are specifying a file's name which isn't a location. The location must exist prior to the copy attempt so you should be able to make an alias of it.

My suggestion would be to copy the file to a different folder than the original then rename it.

Try something like this:

--> cut <--
set dp to (path to desktop as Unicode text)
set source to (dp & "fish_letter.doc") as alias
set dest to "CopiedFiles"

tell application "Finder"
    set dest to make new folder at alias dp with properties {name:dest}
    set nf to duplicate source to dest with replacing
    set name of nf to "fish_letter copied.doc"
end tell
--> cut <--

JBS
--
OK, so what's the speed of dark?
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Why is copying a file so hard? part 3 (From: email@hidden)

  • Prev by Date: Re: "read from" and non-lo-ascii characters
  • Next by Date: Re: scripting barcodes
  • Previous by thread: Re: Why is copying a file so hard? part 3
  • Next by thread: Re: Why is copying a file so hard?
  • Index(es):
    • Date
    • Thread