Home > XModules >

必要なシステム

  • OS X 10.9 以降

ダウンロード

Version 1.3.2 -- 2020-04-22

古いバージョン

依存モジュール

PathInfo

PathInfo は、ファイル参照の変換、およびファイルパスからの様々な情報の取得をオブジェクト指向でおこなえるようにする AppleScript ライブラリです。

AppleScript では、alias、File URL、POSIX パス、HFS パスなど様々なファイル参照形式が使われますが、これらを統一的に扱うことができるようになります。

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*)

更新履歴

  • 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.