• 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: Symlinks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Symlinks


  • Subject: Re: Symlinks
  • From: Tommy Bollman <email@hidden>
  • Date: Sat, 14 Aug 2010 01:44:20 +0200

-- © McUsr 2010 and put in Public Domain see: macscripter.net/viewtopic.php?pid=131797#p131797 for reference and terms of use.
Hello.
I post my heavy duty, which aren't tested in a project yet. It have been tested in the debugger.
Thanks to Yvan, it handles quotes within quoted paths. You should be able to feed it with *anything* (that exists)
It also considers "~" and disks/volumes.
Maybe you can use this?
script PathWay

on hfsPathOfAnythingAsText(anyFileOrFolderPath)
-- returns the full hfs pathname of anything if the files exists
local tids, theFile, lastItem, tidsToUse, singleQuoteCheck -- Thanks to Yvan Koenig :)
set singleQuoteCheck to false
set tidsToUse to ":"
try
(get class of anyFileOrFolderPath)
on error number -1728 -- it was a filereference
set fileOrFolderPath to fileOrFolderPath as alias as text
return fileOrFolderPath
end try
set anyFileOrFolderPath to "" & anyFileOrFolderPath -- doesn't harm.
if anyFileOrFolderPath starts with "'" and anyFileOrFolderPath ends with "'" then
set anyFileOrFolderPath to text 2 thru -2 of anyFileOrFolderPath
set singleQuoteCheck to true
end if
if anyFileOrFolderPath does not start with "/" and anyFileOrFolderPath does not start with "~" then return anyFileOrFolderPath -- we had a hfspath


set {tids, AppleScript's text item delimiters} to {AppleScript's text item delimiters, tidsToUse}
set anyFileOrFolderPath to text items of anyFileOrFolderPath as text
if singleQuoteCheck is true then
set AppleScript's text item delimiters to "'\\''"
set anyFileOrFolderPath to text items of anyFileOrFolderPath -- as list
set AppleScript's text item delimiters to "'"
end if
-- if tidstouse was "/" then we must add the disk name, - but which ???
set anyFileOrFolderPath to "" & anyFileOrFolderPath
set AppleScript's text item delimiters to tidsToUse
if text item 1 of anyFileOrFolderPath is "~" then
set anyFileOrFolderPath to text items 2 thru -2 of (POSIX path of (path to home folder) as text) & text items 2 thru -1 of anyFileOrFolderPath
else if text item 2 of anyFileOrFolderPath is "Volumes" then
set anyFileOrFolderPath to text items 3 thru -1 of anyFileOrFolderPath
else
set anyFileOrFolderPath to {item 1 of (list disks)} & text items 2 thru -1 of anyFileOrFolderPath
end if
set AppleScript's text item delimiters to ":"
set anyFileOrFolderPath to "" & anyFileOrFolderPath
set AppleScript's text item delimiters to tids
return anyFileOrFolderPath
end hfsPathOfAnythingAsText


end script


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: symlinks
  • Next by Date: Re: Symlinks, I sent the wrong handler :-)
  • Previous by thread: Re: What's in an iCal url?
  • Next by thread: Re: Symlinks
  • Index(es):
    • Date
    • Thread