Re: How do I create and name duplicates in the same path as the originals?
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.