PathConverter
PathConverter is an AppleScript module to convet a path form between a relative path and an absolute path each other. Both path styles of POSIX and HFS can be dealt with PathConverter.
use PathConverter : script "PathConverter"
-- HFS Path
set pathconv to PathConverter's make_with("Macintosh HD:Users:tkurita:Documents:hey.txt")
log (relative_path of pathconv for "Macintosh HD:Users:tkurita:articles:hello.txt")
(* ::articles:hello.txt *)
log (absolute_path of pathconv for "::hello.txt")
(* Macintosh HD:Users:tkurita:hello.txt *)
-- POSIX path
set pathconv to PathConverter's make_with("/Users/tkurita/Documents/hey.txt")
log (relative_path of pathconv for "/Users/tkurita/articles/hello.txt")
(* ../articles/hello.txt *)
log (relative_path of pathconv for "/Users/tkurita/Documents/")
(*./*)
log (absolute_path of pathconv for "../articles/hello.txt")
(* /Users/tkurita/articles/hello.txt *)
History
- 1.6 -- 2020-02-03
- Works under AppleScript Libraries
- Removed dependency on ModuleLoader.
- OpenHelpBook.scptd is used instead of HelpBook.osax.
- OS X 10.9 or late is required.
- 1.5 -- 2010-10-22
- ModuleLoader 2.1 or later is required.
- Remove dependency on ShowHelpBook.
- 1.4 -- 2008-03-20
- XText is used instead of StringEngine
- 1.3.1 -- 2008.01.09
- First release with English documents.