Re: How do I create and name duplicates in the same path as the
Re: How do I create and name duplicates in the same path as the
- Subject: Re: How do I create and name duplicates in the same path as the
- From: "Marc K. Myers" <email@hidden>
- Date: Wed, 9 Oct 2002 18:28:38 -0400
From: "Steve Carlson" <email@hidden>
Date: Wed, 9 Oct 2002 01:44:00 -0700 (PDT)
To: <email@hidden>
Subject: How do I create and name duplicates in the same path as the
originals?
Hi everyone - I'm a Perl guy trying to get my feet wet with AS,
and I'm having a hard time figuring out how to do something that I
think
should be fairly simple. I have a droplet that takes a list of files
(JPGs) and should make a duplicate of each file, in the same directory
as
the original. A simple bit of code:
on open myitems
repeat with i from 1 to number of items in myitems
set thisFile to item i of myitems as alias
tell application "Finder" to duplicate file thisFile
end repeat
end open
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:
tell application "Finder" to duplicate file thisFile to file (i &
".jpg")
...but it died at runtime. So I'm wondering, is there some way to
get the parent folder of the files that were dragged onto my droplet,
so I
can correctly specify the full path and filename for my duplicate, or
am I
missing something more simple?
on open (theItems)
set i to 0
repeat with anItem in theItems
set i to i + 1
set newFile to (duplicate (contents of anItem))
set name of newFile to ((i as text) & ".jpg")
end repeat
end open
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[10/09/02 6:28:13 PM]
_______________________________________________
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.