• 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: Getting the path of a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting the path of a file


  • Subject: Re: Getting the path of a file
  • From: "Marc K. Myers" <email@hidden>
  • Date: Sat, 20 Apr 2002 22:55:39 -0400
  • Organization: [very little]

> Date: Sat, 20 Apr 2002 14:27:42 -0600
> Subject: Re: Getting the path of a file.
> From: Jeff Shapiro <email@hidden>
> To: Applescript-Users <email@hidden>
>
> Paul,
>
> Thanks for the help.
>
> However, I guess I should have been more specific. I want the path to the
> file without the filename.
>
> For example:
>
> For the file: Marvin:Users:jshapiro:DeskImages:gos9607_db.jpg
>
> I want a variable that holds only Marvin:Users:jshapiro:DeskImages:
>
> (sorry, about the confusion, but with my background the path is distinct
> from the filename.)
>
> On 4/20/02 1:42 PM, "Paul Berkowitz" <email@hidden> wrote:
>
> > Since you can drop several files and/or folders at once, the 'on open'
> > argument is always a list: a list of aliases. Therefore to get the file (as
> > alias) if you just drop one, you have to get item 1 of that list. To get
> > just its path coerce the alias to string:
> >
> > on open theFiles
> > set theFile to item 1 of theFiles
> > set thePath to theFile as string
> >
> > or, all in one go:
> >
> > on open theFiles
> > set thePath to (item 1 of theFiles) as string

Try this:

on open (itemList)
set thePath to (item 1 of itemList) as text
set {od, AppleScript's text item delimiters} to {AppleScript's text
item delimiters, {":"}}
set thePath to ((text items 1 thru -2 of thePath) as text) & ":"
set AppleScript's text item delimiters to od
thePath
end open

Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[4/20/02 10:54:20 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.

  • Prev by Date: Re: Apple: Please deal with basics
  • Next by Date: Re: Apple: Please deal with basics
  • Previous by thread: Log in at 8am?
  • Next by thread: AS & Basics
  • Index(es):
    • Date
    • Thread