• 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
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]

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


  • Subject: How do I create and name duplicates in the same path as the originals?
  • From: "Steve Carlson" <email@hidden>
  • Date: Wed, 9 Oct 2002 02:01:11 -0700 (PDT)

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?

Thank you in advance for any help you can provide!!
Steve

--
stevesapartment.com
_______________________________________________
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: OS X Name Extensions
  • Next by Date: Re: Is it possible to set up an 'instant' idle handler
  • Previous by thread: [ANN] Ch SDK for C/C++ scripting released
  • Next by thread: Re: How do I create and name duplicates in the same path as the originals?
  • Index(es):
    • Date
    • Thread