Re: Convert File or Path Input into NSURL, HFS path, or POSIX Path Output
Re: Convert File or Path Input into NSURL, HFS path, or POSIX Path Output
- Subject: Re: Convert File or Path Input into NSURL, HFS path, or POSIX Path Output
- From: Christopher Stone <email@hidden>
- Date: Wed, 01 Mar 2017 04:48:23 -0600
On Feb 28, 2017, at 16:59, Shane Stanley <email@hidden> wrote:
# return myNSURL as text -- HFS path
return POSIX path of (myNSURL as text)
FWIW, I'm surprised those two work -- you shouldn't be able to coerce an NSURL to text. … If you want the POSIX path, you should use the path method.
Hey Folks,
By path method he means this:
-------------------------------------------------------------------------------------------
use AppleScript version "2.4" -- Yosemite (10.10) or later use framework "Foundation" use scripting additions
set folderPath to POSIX path of (path to downloads folder)
--> "/Users/myUserName/Downloads/"
set myNSURL to current application's |NSURL|'s fileURLWithPath:folderPath set myFolderPath to myNSURL's |path|() as text -- without the as text coercion you have a NSString
--> "/Users/myUserName/Downloads"
-------------------------------------------------------------------------------------------
This scriptlet if of course redundant.
But you may process a NSURL a great deal before finally outputting a path, and this gives you the bones to do it.
|
_______________________________________________
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