• 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: How do I create and name duplicates in the same path as the originals?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I create and name duplicates in the same path as the originals?


  • Subject: Re: How do I create and name duplicates in the same path as the originals?
  • From: John Delacour <email@hidden>
  • Date: Wed, 9 Oct 2002 10:58:24 +0100
  • Mac-eudora-version: 5.3 alpha

At 2:01 am -0700 9/10/02, Steve Carlson wrote:

This much I can make work, but what I can't seem to figure out is
how to specify the new file's name, rather than use the "foo copy.jpg"
that the Finder picks by default. (I'd like it to be the value of (i &
".jpg")) I also want to have the duplicate reside in the same folder as
the original. I tried something like....


set f1 to ":tmp:junk.txt"
set duplicateName to "hello.txt"
do shell script "rm /private/tmp/hello*" -- least verbose method
open for access file f1 with write permission
set eof file f1 to 0
write "hello" to file f1
close access file f1
tell app "Finder"
set f2ref to duplicate file f1 with replacing
set f2 to f2ref as alias
set name of f2ref to duplicateName
open f2
end

You can also write: duplicate fileref to folderref if you want the duplicate in a different folder.

The f2Ref->f2 coercion to alias enables the Finder to locate and open the file in spite of its changed name.

JD
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Is it possible to set up an 'instant' idle handler
  • Next by Date: Re: How do I create and name duplicates in the same path as the originals?
  • Previous by thread: Re: How do I create and name duplicates in the same path as the originals?
  • Next by thread: AS 1.8.3
  • Index(es):
    • Date
    • Thread