• 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: get alias from ~/path
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: get alias from ~/path


  • Subject: Re: get alias from ~/path
  • From: John Delacour <email@hidden>
  • Date: Sat, 1 Mar 2003 13:34:16 +0000
  • Mac-eudora-version: 6.0a8

At 11:53 pm -0700 28/2/03, Donald Hall wrote:

This seems to work on my machine. Is 'id' the right command to use?
There is also 'logname'.

You can get the path in one go by doing

(do shell script "cd;pwd") & "/"

or

POSIX path of (path to "cusr")


set fileName to "~/Documents"
getAlias(fileName)

on getAlias(f)
if f starts with "~" then
set f to (do shell script "cd;pwd") & text 2 through -1 of f
end if
return POSIX file f as alias
end getAlias


You have the line << "/" & (characters 2 thru -1 of pathName) as text" >>

It is not necessary to write "as text" or "as string" when you are concatenating string+list in that order. It is also better to use <<text x through y>>. The chain will take the class of the first item .... cfr:

{1, 2} & 3
--> {1, 2, 3}

1 & {2, 3}
--> {1, 2, 3}

"1" & {2, 3}
--> "123"

1 & 2
--> {1, 2}

1 & "2"
--> {1, "2"}

"1" & 2
-->"12"

"!!!" & (path to "cusr")
--> "!!!dx:Users:jd:"


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: Writing Applescripts that run "quietly"?
  • Next by Date: Q: Using ResEdit to view [scpt] resources (to inspect properties)
  • Previous by thread: Re: Writing Applescripts that run "quietly"?
  • Next by thread: Re: get alias from ~/path
  • Index(es):
    • Date
    • Thread