« [componentsToDisplayForPath]パスをディレクトリ毎に分解したリスト | トップページ | [attributesOfItemAtPath]属性の取得 »

[changeCurrentDirectoryPath]作業用ディレクトリの移動

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "UniformTypeIdentifiers"
use scripting additions

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
set objFileManager to objMe's NSFileManager's defaultManager()

tell application "Finder"
set aliasPathToDesktop to path to desktop folder from user domain
end tell
##
set strPathToDesktop to POSIX path of aliasPathToDesktop
###NSString
set objPathToMe to objNSString's stringWithString:strPathToDesktop
####################################
####この時点でのカレントディレクトリ
set ocidCurrentDirectoryPath to objFileManager's currentDirectoryPath

log ocidCurrentDirectoryPath
log ocidCurrentDirectoryPath's className() as text
-->(*__NSCFString*)
log ocidCurrentDirectoryPath as list
-->(*/*)
##################################
####デスクトップに作業ディレクトリを移動
set ocidPathToDesktop to objFileManager's changeCurrentDirectoryPath:strPathToDesktop

log ocidCurrentDirectoryPath
log ocidCurrentDirectoryPath's className() as text
-->(*__NSCFString*)
log ocidCurrentDirectoryPath as text
-->(*/Users/ユーザー名/Desktop*)

####################################
####ディレクトリが移動した事の確認
set ocidCurrentDirectoryPath to objFileManager's currentDirectoryPath

log ocidCurrentDirectoryPath
log ocidCurrentDirectoryPath's className() as text
-->(*__NSCFString*)
log ocidCurrentDirectoryPath as list
-->(*/Users/ユーザー名/Desktop*)

|

« [componentsToDisplayForPath]パスをディレクトリ毎に分解したリスト | トップページ | [attributesOfItemAtPath]属性の取得 »

AppleScript NSFileManager」カテゴリの記事