Home > XModules >

Requirements

  • OS X 10.9 or later
    • Developed and tested on macOS 10.14.6

Download

Version 1.3.2 -- 2020-04-22

Old Versions

Dependencies

PathInfo

PathInfo is an AppleScript library which provides object oriented interface to deal with file references.

In AppleScript various kind of file references are used i.e. alias, File URL, HFS path and POSIX path. PathInfo allow to unified way to convert each others and to obtain various infomation from file references.

use PathInfo : script "PathInfo"

set a_path to "/System/Library/CoreServices/Finder.app/"

(*** Class methods ***)
log PathInfo's name_of(a_path)
(*Finder.app*)
log PathInfo's basename_of(a_path)
(*Finder*)
log PathInfo's path_extension_of(a_path)
(*app*)
log PathInfo's split_name("basename.txt")
(*basename, txt*)
log PathInfo's folder_of(a_path)
(*/System/Library/CoreServices/*)

(*** Obtain path infomation ***)
set a_pathinfo to PathInfo's make_with(a_path)
log a_pathinfo's item_name()
(*Finder.app*)
log a_pathinfo's basename()
(*Finder*)
log a_pathinfo's path_extension()
(*app*)
log a_pathinfo's is_folder()
(*true*)
log a_pathinfo's item_exists()
(*true*)
log a_pathinfo's is_posix()
(*true*)

(*** Converting reference form ***)
log a_pathinfo's as_alias()
(*alias Macintosh HD:System:Library:CoreServices:Finder.app:*)
log a_pathinfo's as_furl()
(*file Macintosh HD:System:Library:CoreServices:Finder.app:*)
log a_pathinfo's posix_path()
(*/System/Library/CoreServices/Finder.app/*)
log a_pathinfo's hfs_path()
(*Macintosh HD:System:Library:CoreServices:Finder.app:*)

(*** Making a new instance from the instance ***)
log a_pathinfo's parent_folder()'s posix_path()
(*/System/Library/CoreServices/*)
log a_pathinfo's change_name("new_item")'s posix_path()
(*/System/Library/CoreServices/new_item/*)
log a_pathinfo's change_path_extension("txt")'s posix_path()
(*/System/Library/CoreServices/Finder.txt/*)
log a_pathinfo's change_folder("/aaa/bbb/")'s posix_path()
(*/aaa/bbb/Finder.app/*)
log a_pathinfo's child("child_item")'s posix_path()
(*/System/Library/CoreServices/Finder.app/child_item*)

History

  • 1.3.2 -- 2020-04-20
    • Fixed : did not work on OS X 10.9
  • 1.3.1 -- 2020-02-04
    • Added as_NSURL handler.
  • 1.3 -- 2020-01-28
    • Use OpenHelpBook.osax instead of HelpBook.osax.
    • Added as_alias_without_update
    • OS X 10.9 or later is required.
  • 1.2.3 -- 2017-02-10
    • Mac OS X 10.6 or later is required, because the help book bundle is updated.
    • Update the help book.
  • 1.2.2 -- 2012-11-08
    • Fixed errors with AppleScriptObjC.
      • In AppleScriptObjC, POSX file "path to file" must be rewiritten to "path to file" as POSIX file.
  • 1.2.1 -- 2012-05-31
    • Added "clone".
  • 1.2 -- 2012-05-25
    • Added "normalized_posix_path"
  • 1.1 -- 2012-05-11
    • added "item_exists_without_update"
    • Update Help.
      • Improved layout for small windows of the Help Viewer.
      • Fixed : "Edit Link" and "Clipboard Icon" links does not work in Mac OS X 10.6.
  • 1.0.1 -- 2011-02-10
    • make_with handler can expand "~" as user's home directory.
  • 1.0 -- 2010-03-23
    • First release.