Re: File URL to Alias?
Re: File URL to Alias?
- Subject: Re: File URL to Alias?
- From: "koenig.yvan" <email@hidden>
- Date: Tue, 25 Feb 2014 14:21:35 +0100
Le 25/02/2014 à 12:32, Shane Stanley < email@hidden> a écrit : On 25 Feb 2014, at 10:12 am, Shane Stanley < email@hidden> wrote: use framework "Foundation" on pathFromTextURL:theURL set thePath to current application's NSString's stringWithString:theURL -- make an NSString set thePath to thePath's stringByReplacingPercentEscapesUsingEncoding:(current application's NSUTF8StringEncoding) -- replace encoded chars set theStart to location of (thePath's rangeOfString:"/") -- find / to reomve file: bit return (thePath's substringFromIndex:theStart) as text end pathFromTextURL:
I was asked off-list about how this would cope with URLs beginning with "file//localhost". The answer is, not very well. In my defence, URLs created under Mavericks no longer include localhost.
But I realised there's an easier method than the above, which shouldn't care about localhost or the extra slashes:
use framework "Foundation" on pathFromTextURL:theURL return (current application's NSURL's URLWithString:theURL)'s |path|() as text end pathFromTextURL:
No need for « defence » Shane.
In fact, URLs created under Mavericks are supposed to no longer include localhost.
It seems that the problem is not a system one but an application one.
Numbers 2.3 returns TextWrangler 4.5.6 returns SketchBook Pro 5.5.6 returns VLC 2.1.4 returns
But Numbers 3.1 returns File Viewer 1.4 returns TextEdit 1.9 returns
Of course, the late code treat well both cases.
Yvan KOENIG (VALLAURIS, France) mardi 25 février 2014 14:19:36
|
_______________________________________________
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