• 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, I sent the wrong handler :-)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Symlinks, I sent the wrong handler :-)


  • Subject: Re: Symlinks, I sent the wrong handler :-)
  • From: Tommy Bollman <email@hidden>
  • Date: Sat, 14 Aug 2010 01:47:12 +0200

Hello.
Maybe you can use this
-- © McUsr 2010 and put in Public Domain see: macscripter.net/viewtopic.php?pid=131797#p131797 for reference and terms of use.
on posixPathOfAnytingAsText(anyFileOrFolderPath)
-- returns the full posix 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 anyFileOrFolderPath to POSIX path of (anyFileOrFolderPath as alias) as text
return anyFileOrFolderPath
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 starts with "/" and singleQuteCheck is false then
return anyFileOrFolderPath
else if anyFileOrFolderPath starts with "/" or anyFileOrFolderPath starts with "~" then
set tidsToUse to "/"
end if


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
set anyFileOrFolderPath to "" & anyFileOrFolderPath
set AppleScript's text item delimiters to tidsToUse


if tidsToUse is ":" then
-- the first item isn' like disk nr 1 then we have to do something.
if text item 1 of anyFileOrFolderPath is not item 1 of (list disks) then
set anyFileOrFolderPath to {"Volumes"} & text items of anyFileOrFolderPath
else
set anyFileOrFolderPath to {""} & text items 2 thru -1 of anyFileOrFolderPath
end if
set AppleScript's text item delimiters to "/"
else if text item 1 of anyFileOrFolderPath is "~" then
-- mus get the posix path as text
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
end if
set anyFileOrFolderPath to "" & anyFileOrFolderPath
set AppleScript's text item delimiters to tids
return anyFileOrFolderPath
end posixPathOfAnytingAsText
 _______________________________________________
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
  • Previous by thread: Re: Symlinks
  • Next by thread: Re: Script to create a network
  • Index(es):
    • Date
    • Thread