Monday, November 19, 2018

#1 2018-09-13 04:25:17 am

Joy
Member
From:: South Tirol
Registered: 2008-07-04
Posts: 579
Website

Convert hfs to uri path

I was wondering to find no relevant topics online,
about how to convert hfs paths into an uri paths.
Ideally I look for a code wrap to insert paths as links in applications which support this features, of course.
Thanks for any suggestion

Offline

 

#2 2018-09-13 05:32:13 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5471

Re: Convert hfs to uri path

You can use System Events:

Applescript:

set aFile to path to desktop
tell application id "com.apple.systemevents" -- System Events.app
   set theURI to URL of aFile
end tell


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#3 2018-09-15 08:39:09 am

Frankv
Member
From:: Amsterdam, NL
Registered: 2017-09-11
Posts: 6

Re: Convert hfs to uri path

You can also use the Finder for this.

Applescript:

set aFile to path to desktop
tell application "Finder" to set theURI to URL of item aFile

Offline

 

#4 2018-09-25 08:32:28 am

Joy
Member
From:: South Tirol
Registered: 2008-07-04
Posts: 579
Website

Re: Convert hfs to uri path

Works great!
At this point a curious question: is it possible to convert local files (uri- files) to URL files? I think it makes no sense because uri files are local URLs.. And conventional URLs are online -not local- files.

Offline

 

#5 2018-09-25 10:22:01 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11520
Website

Re: Convert hfs to uri path

URLs are URLs. They start always with a scheme, for example


- Local file URLs start with file://
- Remote URLs start with http:// or https://
- FTP URLs start with ftp://
- URLs to launch AppleScripts from web pages start with applescript://

and so on.

On the other hand a POSIX path is a file URL without the file:// scheme

Last edited by StefanK (2018-09-25 10:22:22 am)


regards

Stefan

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)