« [NSURL] homeDirectoryForUser | トップページ | [Printer]スプールフォルダを開く »

[FileManager]createDirectoryAtURL:withIntermediateDirectories:attributes:error:

#!/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 scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSURL : a reference to objMe's NSURL
property objUTType : a reference to objMe's UTType

property objNSNotFound : a reference to 9.22337203685477E+18 + 5807

set objFileManager to objMe's NSFileManager's defaultManager()



###ユーザーアプリケーションフォルダを作る
set ocidUserApplicationsPathList to (objFileManager's URLsForDirectory:(objMe's NSApplicationDirectory) inDomains:(objMe's NSUserDomainMask))
log ocidUserApplicationsPathList as list
log className() of ocidUserApplicationsPathList as text


set ocidUserApplicationsPath to ocidUserApplicationsPathList's objectAtIndex:0
log ocidUserApplicationsPath as list
log className() of ocidUserApplicationsPath as text


set boolMakeNewFolder to (objFileManager's createDirectoryAtURL:ocidUserApplicationsPath withIntermediateDirectories:true attributes:(missing value) |error|:(missing value))
log boolMakeNewFolder as boolean
log class of boolMakeNewFolder


if boolMakeNewFolder is false then
log "フォルダ作成でエラーしました"
error "" number -128
return
end if


#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat

end doLogView
#########################

|

« [NSURL] homeDirectoryForUser | トップページ | [Printer]スプールフォルダを開く »

AppleScript NSFileManager」カテゴリの記事