AppleScript Microsoft

[Fonts]Microsoft Officeの付属フォントのGDIファミリー名一覧 を取得する(ちょっと修正)


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# ダイアログでfontsGDIFamilyNames.plistを選んでください
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKIt"
use framework "UniformTypeIdentifiers"
use scripting additions

property refMe : a reference to current application

########################################
#######ファイル選択
---プロンプトの文言改行が使えます\nを入れます
set theWithPrompt to "ファイルを選択してください"
---ファイル選択ダイアログのデフォルトのディレクトリ
try
  set aliasDefaultLocation to (POSIX file "/Applications/Microsoft PowerPoint.app/Contents/Resources") as alias
on error
return "Microsoft Officeをインストールしてないとファイルがないです"
end try

set theFileTypeList to {"com.apple.property-list"}
---ダイアログを出して選択されたファイルは「open」に渡す
set aliasFilePath to (choose file default location aliasDefaultLocation ¬
  with prompt theWithPrompt ¬
  of type theFileTypeList ¬
invisibles false ¬
  with showing package contents without multiple selections allowed) as alias
####入力ファイル関連
set strFilePath to POSIX path of aliasFilePath as text
###NSストリングに
set ocidFilePath to refMe's NSString's stringWithString:strFilePath
###NSURLに
set ocidFilePathURL to refMe's NSURL's fileURLWithPath:ocidFilePath
##ファイル名取得
set strFileName to (ocidFilePathURL's lastPathComponent) as text

########################################
######出力ファイル
##ファイル名
set strFileName to (strFileName & ".html") as text
set aliasSaveFilePath to choose file name with prompt "htmlのファイル名を付けてください" default name strFileName default location (aliasDefaultLocation)
###パス
set strSaveFilePath to POSIX path of aliasSaveFilePath as text
###NSストリングに
set ocidSaveFilePath to refMe's NSString's stringWithString:strSaveFilePath
###NSURLに
set ocidSaveFilePathURL to refMe's NSURL's fileURLWithPath:ocidSaveFilePath
##拡張子
set strFileExtension to (ocidFilePathURL's pathExtension) as text
###拡張子つけ忘れ対策
if strFileExtension is not "html" then
  set strSaveFilePath to (POSIX path of aliasSaveFilePath & ".html") as text
  ###NSストリングに
  set ocidSaveFilePath to refMe's NSString's stringWithString:strSaveFilePath
  ###NSURLに
  set ocidSaveFilePathURL to refMe's NSURL's fileURLWithPath:ocidSaveFilePath
end if

########################################
######データ処理
###PLISTのデータをレコードとして読み込む
set ocidReadPlistData to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)

set ocidPlistDict to item 1 of ocidReadPlistData
set ocidAllKeysArray to ocidPlistDict's allKeys()

set ocidAllKeyArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
ocidAllKeyArray's addObjectsFromArray:(ocidAllKeysArray)
##############################
####並び替え並び替え compare
(*
compare:
caseInsensitiveCompare:
localizedCompare:
localizedStandardCompare:
localizedCaseInsensitiveCompare:
*)
#NSSortDescriptor's
set ocidSortDescriptorsArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
set ocidSortDescriptor to (refMe's NSSortDescriptor's sortDescriptorWithKey:"self" ascending:(true) selector:"localizedStandardCompare:")
ocidSortDescriptorsArray's addObject:(ocidSortDescriptor)
##
ocidAllKeyArray's sortUsingDescriptors:(ocidSortDescriptorsArray)
#######################################
##まずはHTMLの基本的部分を生成
########################################
#headerに渡すエレメント
set ocidH3Element to refMe's NSXMLElement's elementWithName:("h3")
(ocidH3Element's setStringValue:("Microsoft Officeの付属フォントのGDIファミリー名一覧"))

########################################
#footerに渡すエレメント
set ocidFotterAElement to refMe's NSXMLElement's elementWithName:("a")
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("href") stringValue:("https://quicktimer.cocolog-nifty.com/"))
(ocidFotterAElement's addAttribute:(ocidAddNode))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("target") stringValue:("_blank"))
(ocidFotterAElement's addAttribute:(ocidAddNode))
set strContents to ("AppleScriptで生成しました") as text
(ocidFotterAElement's setStringValue:(strContents))

########################################
#articleに渡すエレメント
#テーブル部生成開始
set ocidTableElement to refMe's NSXMLElement's elementWithName:("table")
#####【caption】
set ocidCaptionElement to refMe's NSXMLElement's elementWithName:("caption")
ocidCaptionElement's setStringValue:("Microsoft Officeの付属フォントのGDIファミリー名一覧")
ocidTableElement's addChild:(ocidCaptionElement)
#####【colgroup】
set ocidColgroupElement to refMe's NSXMLElement's elementWithName:("colgroup")
#タイトル部の数だけ繰り返し
set listColName to {"LineNo", "ファミリー名", "フォント名"} as list
repeat with itemColName in listColName
  #######【col】col生成
  set ocidAddElement to (refMe's NSXMLElement's elementWithName:("col"))
  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(itemColName))
(ocidAddElement's addAttribute:(ocidAddNode))
(ocidColgroupElement's addChild:(ocidAddElement))
end repeat
#テーブルエレメントに追加
ocidTableElement's addChild:(ocidColgroupElement)
#######【thead】
set ocidTheadElement to refMe's NSXMLElement's elementWithName:("thead")
#TR
set ocidTrElement to refMe's NSXMLElement's elementWithName:("tr")
#タイトル部の数だけ繰り返し
repeat with itemColName in listColName
  if (itemColName as text) is "LineNo" then
    #ここはTDではなくてTHを利用
    set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th"))
    ####項番処理
    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(itemColName))
(ocidAddElement's addAttribute:(ocidAddNode))
    #
    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("id") stringValue:(itemColName))
(ocidAddElement's addAttribute:(ocidAddNode))
    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
(ocidAddElement's addAttribute:(ocidAddNode))
    #値を入れる
(ocidAddElement's setStringValue:("\"))
    #TH→TRにセット
(ocidTrElement's addChild:(ocidAddElement))
  else
    #ここはTDではなくてTHを利用
    set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th"))
    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(itemColName))
(ocidAddElement's addAttribute:(ocidAddNode))
    #
    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("id") stringValue:(itemColName))
(ocidAddElement's addAttribute:(ocidAddNode))
    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
(ocidAddElement's addAttribute:(ocidAddNode))
    #値を入れる
(ocidAddElement's setStringValue:(itemColName))
    #TH→TRにセット
(ocidTrElement's addChild:(ocidAddElement))
  end if
end repeat
#TRをTHEADにセット
ocidTheadElement's addChild:(ocidTrElement)
#THEADをテーブルにセット
ocidTableElement's addChild:(ocidTheadElement)

##################################
#本処理
######【tbody】
set ocidTbodyElement to refMe's NSXMLElement's elementWithName:("tbody")
set numCntRow to 1 as integer
repeat with itemArray in ocidAllKeyArray
  #TRの開始
  set ocidTrElement to (refMe's NSXMLElement's elementWithName:("tr"))
  ####項番処理
  set ocidThElement to (refMe's NSXMLElement's elementWithName:("th"))
  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("項目番号:" & numCntRow))
(ocidThElement's addAttribute:(ocidAddNode))
  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:("LineNo"))
(ocidThElement's addAttribute:(ocidAddNode))
  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
(ocidThElement's addAttribute:(ocidAddNode))
(ocidThElement's setStringValue:(numCntRow as text))
(ocidTrElement's addChild:(ocidThElement))
  ##################################
  set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td"))
  #
  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(itemArray as text))
(ocidTdElement's addAttribute:(ocidAddNode))
(ocidTdElement's setStringValue:(itemArray as text))
(ocidTrElement's addChild:(ocidTdElement))
  ##################################
  set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td"))
  #
  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("フォント名"))
(ocidTdElement's addAttribute:(ocidAddNode))
  #
  set ocidItemArray to (ocidPlistDict's objectForKey:(itemArray))
  set strSetValue to ("") as text
  repeat with itemValue in ocidItemArray
    set strSetValue to strSetValue & (itemValue as text) & "\n"
  end repeat
(ocidTdElement's setStringValue:(strSetValue))
(ocidTrElement's addChild:(ocidTdElement))
  
(ocidTbodyElement's addChild:(ocidTrElement))
  set numCntRow to numCntRow + 1 as integer
end repeat
#TBODYをテーブルにセット
ocidTableElement's addChild:(ocidTbodyElement)


######【tfoot】 TRで
set ocidTfootElement to refMe's NSXMLElement's elementWithName:("tfoot")
set ocidTrElement to refMe's NSXMLElement's elementWithName:("tr")
#項目数を取得して
set numCntCol to (count of listColName) as integer
#colspan指定して1行でセット
set ocidThElement to (refMe's NSXMLElement's elementWithName:("th"))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("テーブルの終わり"))
(ocidThElement's addAttribute:(ocidAddNode))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("colspan") stringValue:(numCntCol as text))
(ocidThElement's addAttribute:(ocidAddNode))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("row"))
(ocidThElement's addAttribute:(ocidAddNode))
#
set numCntContents to (count of ocidAllKeyArray) as integer
set strContents to ("項目数 : " & (numCntContents - 1)) as text
(ocidThElement's setStringValue:(strContents))
#THをTRにセットして
ocidTrElement's addChild:(ocidThElement)
#TRをTFOOTにセット
ocidTfootElement's addChild:(ocidTrElement)
#TFOOTをテーブルにセット
ocidTableElement's addChild:(ocidTfootElement)

##############################
#HTMLにする
##############################
set ocidHTML to doMakeRootElement({ocidH3Element, ocidTableElement, ocidFotterAElement})
##############################
#保存
##############################
#読み取りやすい表示
set ocidXMLdata to ocidHTML's XMLDataWithOptions:(refMe's NSXMLNodePrettyPrint)


set listDone to ocidXMLdata's writeToURL:(ocidSaveFilePathURL) options:(refMe's NSDataWritingAtomic) |error|:(reference)

####【6】ブラウザで開く
set aliasFilePath to (ocidSaveFilePathURL's absoluteURL()) as alias
tell application "Finder"
open location aliasFilePath
end tell










############################################################
# 基本的なHTMLの構造
(*
doMakeRootElement({argHeaderContents, argArticleContents, argFooterContents})
HTMLのBODY部
header
article
footerにそれぞれAddchildするデータをリストで渡す
戻り値はRootエレメントにセットされた
NSXMLDocumentを戻すので 保存すればOK
*)
############################################################
to doMakeRootElement({argHeaderContents, argArticleContents, argFooterContents})
  #XML初期化
  set ocidXMLDoc to refMe's NSXMLDocument's alloc()'s init()
ocidXMLDoc's setDocumentContentKind:(refMe's NSXMLDocumentHTMLKind)
  # DTD付与
  set ocidDTD to refMe's NSXMLDTD's alloc()'s init()
ocidDTD's setName:("html")
ocidXMLDoc's setDTD:(ocidDTD)
  #
  set ocidRootElement to refMe's NSXMLElement's elementWithName:("html")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("lang") stringValue:("ja")
ocidRootElement's addAttribute:(ocidAddNode)
  #
  set ocidHeadElement to refMe's NSXMLElement's elementWithName:("head")
  #
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("title")
ocidAddElement's setStringValue:("ImageList")
ocidHeadElement's addChild:(ocidAddElement)
  # http-equiv
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("http-equiv") stringValue:("Content-Type")
ocidAddElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("text/html; charset=UTF-8")
ocidAddElement's addAttribute:(ocidAddNode)
ocidHeadElement's addChild:(ocidAddElement)
  #
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("name") stringValue:("viewport")
ocidAddElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("width=720")
ocidAddElement's addAttribute:(ocidAddNode)
ocidHeadElement's addChild:(ocidAddElement)
  #
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("style")
ocidAddElement's setStringValue:("body {margin: 10px;background-color: #FFFFFF;}table {max-width: 1280px;border-spacing: 0;caption-side: top;font-family: system-ui;}thead th {border: solid 1px #666666;padding: .5ch 1ch;border-block-width: 1px 0;border-inline-width: 1px 0;&:first-of-type {border-start-start-radius: .5em}&:last-of-type {border-start-end-radius: .5em;border-inline-end-width: 1px}}tbody th {border-spacing: 0;width: 40px !important;border: solid 1px #666666;padding: .5ch 1ch;border-block-width: 1px 0;border-inline-width: 1px 0;}tbody td {word-wrap: break-word;width: 720px;max-width: 720px;border-spacing: 0;border: solid 1px #666666;padding: .5ch 1ch;border-block-width: 1px 0;border-inline-width: 1px 0;&:last-of-type {border-inline-end-width: 1px}}tbody tr:nth-of-type(odd) {background: #F2F2F2;}.kind_string {font-size: 0.75em;}.date_string {font-size: 0.5em;}tfoot th {border: solid 1px #666666;padding: .5ch 1ch;&:first-of-type {border-end-start-radius: .5em}&:last-of-type {border-end-end-radius: .5em;border-inline-end-width: 1px}}img {max-width: 720px;}")
ocidHeadElement's addChild:(ocidAddElement)
ocidRootElement's addChild:(ocidHeadElement)
  #
  #ボディエレメント
  set ocidBodyElement to refMe's NSXMLElement's elementWithName:("body")
  #ヘッダー
  set ocidHeaderElement to refMe's NSXMLElement's elementWithName:("header")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("id") stringValue:("header")
ocidHeaderElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_header")
ocidHeaderElement's addAttribute:(ocidAddNode)
ocidHeaderElement's addChild:(argHeaderContents)
ocidBodyElement's addChild:(ocidHeaderElement)
  #アーティクル
  set ocidArticleElement to refMe's NSXMLElement's elementWithName:("article")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("id") stringValue:("article")
ocidArticleElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_article")
ocidArticleElement's addAttribute:(ocidAddNode)
ocidArticleElement's addChild:(argArticleContents)
  set ocidH6Element to refMe's NSXMLElement's elementWithName:("h6")
(ocidH6Element's setStringValue:("イメージ一覧"))
ocidArticleElement's addChild:(ocidH6Element)
ocidBodyElement's addChild:(ocidArticleElement)
  #フッター
  set ocidFooterElement to refMe's NSXMLElement's elementWithName:("footer")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("id") stringValue:("footer")
ocidFooterElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_footer")
ocidFooterElement's addAttribute:(ocidAddNode)
ocidFooterElement's addChild:(argFooterContents)
ocidBodyElement's addChild:(ocidFooterElement)
  #ボディをROOTエレメントにセット
ocidRootElement's addChild:(ocidBodyElement)
  #ROOTをXMLにセット
ocidXMLDoc's setRootElement:(ocidRootElement)
  #値を戻す
return ocidXMLDoc
end doMakeRootElement

|

Microsoft Fontsダウンロード


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application



set strURL to ("https://go.microsoft.com/fwlink/?linkid=525136") as text

################################
#ファイルのダウンロード先
#起動時に削除される項目
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidTempDirURL to appFileManager's temporaryDirectory()
set ocidUUID to refMe's NSUUID's alloc()'s init()
set ocidUUIDString to ocidUUID's UUIDString
set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:true
#フォルダ生成
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
#リダイレクト先のURLを取得
set strCommandText to ("/usr/bin/curl -s -L -I -o /dev/null -w '%{url_effective}' \"" & strURL & "\"") as text
set strURL to (do shell script strCommandText) as text
################################
set ocidURLString to refMe's NSString's stringWithString:(strURL)
set ocidURL to refMe's NSURL's alloc()'s initWithString:(ocidURLString)
#リダイレクト先のURLからダウンロードファイル名
set ocidFileName to ocidURL's lastPathComponent() as text
#ダウンロード先URLからパス
set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(ocidFileName)
set strSaveFilePath to ocidSaveFilePathURL's |path| as text
#ファイルダウンロード
set strCommandText to ("/usr/bin/curl -L -o \"" & strSaveFilePath & "\" \"" & strURL & "\" --http1.1 --connect-timeout 20") as text
set strResponse to (do shell script strCommandText) as text
################################
#PKGの解凍先ディレクトリ
set ocidExpandDirPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("expand")
set strExpandDirPath to ocidExpandDirPathURL's |path| as text
#ダウンロードしたPKGの解凍
set theComandText to "/usr/sbin/pkgutil --expand \"" & strSaveFilePath & "\" \"" & strExpandDirPath & "\"" as text
do shell script theComandText
################################
#解凍するPayloadのURL
set ocidPayloadFilePathURL to ocidExpandDirPathURL's URLByAppendingPathComponent:("Microsoft_PowerPoint.pkg/Payload")
#Payloadを解凍する解凍先URL
set ocidPayloadExpandDirPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("Payload")
#解凍するPayloadのパス
set strPayloadFilePath to ocidPayloadFilePathURL's |path| as text
#解凍先のディレクトリ
set strPayloadExpandFilePath to ocidPayloadExpandDirPathURL's |path| as text
#Payloadの解凍
set theComandText to ("/usr/bin/ditto -xz \"" & strPayloadFilePath & "\" \"" & strPayloadExpandFilePath & "\"") as text
do shell script theComandText
################################
#解凍されたPayloadのフォントディレクトリ
set ocidDFontsDirPathURL to ocidPayloadExpandDirPathURL's URLByAppendingPathComponent:("Microsoft PowerPoint.app/Contents/Resources/DFonts")
#ユーザーのライブラリディレクトリ
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
#解凍したDFontsの移動先
set ocidDistDirPathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Fonts/Microsoft Fonts")
#DFontsをユーザーのFontsフォルダへ移動
set listDone to appFileManager's moveItemAtURL:(ocidDFontsDirPathURL) toURL:(ocidDistDirPathURL) |error|:(reference)
return

|

Microsoft Teams classic キャッシュクリア(キャッシュをゴミ箱へ)


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
# Microsoft Teams classicのキャッシュ2ゴミ箱
# 先に主要なアプリは終了させてから 
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKIt"
use framework "UniformTypeIdentifiers"
use scripting additions
property refMe : a reference to current application

set strBundleID to ("com.microsoft.teams") as text


set appFileManager to refMe's NSFileManager's defaultManager()
###
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSCachesDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidCachesDirPathURL to ocidURLsArray's firstObject()
set ocidGo2TrashDirPathURL to ocidCachesDirPathURL's URLByAppendingPathComponent:("com.microsoft.teams")
log doMoveToTrash(ocidGo2TrashDirPathURL)
###
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidApplicatioocidupportDirPathURL to ocidURLsArray's firstObject()
set ocidTeamsDirPathURL to ocidApplicatioocidupportDirPathURL's URLByAppendingPathComponent:("Microsoft/Teams")
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("GPUCache")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Code Cache")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Cache")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Crashpad")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Local Storage")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("WebStorage")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Session Storage")
log doMoveToTrash(ocidGo2TrashDirPathURL)
###
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/Service Worker")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/Local Storage")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/WebStorage")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/Session Storage")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/GPUCache")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/Code Cache")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/Cache")
log doMoveToTrash(ocidGo2TrashDirPathURL)
#
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/Storage/ext")
log doMoveToTrash(ocidGo2TrashDirPathURL)
###
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
#
set ocidGo2TrashDirPathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("WebKit/com.microsoft.teams")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Application Scripts/UBF8T346G9.com.microsoft.teams")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Group Containers/UBF8T346G9.com.microsoft.teams/Library/Application Support/Logs")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Group Containers/UBF8T346G9.com.microsoft.teams/Library/Caches")
log doMoveToTrash(ocidGo2TrashDirPathURL)


return

###################################
########処理 ゴミ箱に入れる
###################################
to doMoveToTrash(argFilePath)
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  #########################################
  ###渡された値のClassを調べてとりあえずNSURLにする
  set refClass to class of argFilePath
  if refClass is list then
return "エラー:リストは処理しません"
  else if refClass is text then
log "テキストパスです"
    set ocidArgFilePathStr to (refMe's NSString's stringWithString:argFilePath)
    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
  else if refClass is alias then
log "エイリアスパスです"
    set strArgFilePath to (POSIX path of argFilePath) as text
    set ocidArgFilePathStr to (refMe's NSString's stringWithString:strArgFilePath)
    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
  else
    set refClass to (className() of argFilePath) as text
    if refClass contains "NSPathStore2" then
log "NSPathStore2です"
      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:argFilePath)
    else if refClass contains "NSCFString" then
log "NSCFStringです"
      set ocidArgFilePath to argFilePath's stringByStandardizingPath
      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
    else if refClass contains "NSURL" then
      set ocidArgFilePathURL to argFilePath
log "NSURLです"
    end if
  end if
  #########################################
  ###
  -->false
  set ocidFalse to (refMe's NSNumber's numberWithBool:false)'s boolValue
  -->true
  set ocidTrue to (refMe's NSNumber's numberWithBool:true)'s boolValue
  #########################################
  ###NSURLがエイリアス実在するか?
  set ocidArgFilePath to ocidArgFilePathURL's |path|()
  set boolFileAlias to appFileManager's fileExistsAtPath:(ocidArgFilePath)
  ###パス先が実在しないなら処理はここまで
  if boolFileAlias = false then
log ocidArgFilePath as text
log "処理中止 パス先が実在しない"
return false
  end if
  #########################################
  ###NSURLがディレクトリなのか?ファイルなのか?
  set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsDirectoryKey) |error|:(reference)
  # log (item 1 of listBoolDir)
  # log (item 2 of listBoolDir)
  # log (item 3 of listBoolDir)
  if (item 2 of listBoolDir) = ocidTrue then
    #########################################
log "ディレクトリです"
log ocidArgFilePathURL's |path| as text
    ##内包リスト
    set listResult to appFileManager's contentsOfDirectoryAtURL:ocidArgFilePathURL includingPropertiesForKeys:{refMe's NSURLPathKey} options:0 |error|:(reference)
    ###結果
    set ocidContentsPathURLArray to item 1 of listResult
    ###リストの数だけ繰り返し
    repeat with itemContentsPathURL in ocidContentsPathURLArray
      ###ゴミ箱に入れる
      set listResult to (appFileManager's trashItemAtURL:itemContentsPathURL resultingItemURL:(missing value) |error|:(reference))
    end repeat
  else
    #########################################
log "ファイルです"
    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsAliasFileKey) |error|:(reference)
    if (item 2 of listBoolDir) = ocidTrue then
log "エイリアスは処理しません"
return false
    end if
    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsSymbolicLinkKey) |error|:(reference)
    if (item 2 of listBoolDir) = ocidTrue then
log "シンボリックリンクは処理しません"
return false
    end if
    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsSystemImmutableKey) |error|:(reference)
    if (item 2 of listBoolDir) = ocidTrue then
log "システムファイルは処理しません"
return false
    end if
    ###ファイルをゴミ箱に入れる
    set listResult to (appFileManager's trashItemAtURL:ocidArgFilePathURL resultingItemURL:(missing value) |error|:(reference))
  end if
return true
end doMoveToTrash



|

Microsoft Teams (work or school)バージョンチェッカー


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
(*
com.cocolog-nifty.quicktimer.icefloe
*)
#
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application

###アプリケーションのバンドルID
set strBundleID to "com.microsoft.teams2"

set strGetBundleID to "com.microsoft.teams2.standalone" as text
(* インストールパッケージのバンドルID
com.microsoft.office.suite.365
com.microsoft.office.suite.365.businesspro
com.microsoft.word.standalone.365
com.microsoft.excel.standalone.365
com.microsoft.powerpoint.standalone.365
com.microsoft.outlook.standalone.365
com.microsoft.outlook.standalone.365.monthly
com.microsoft.onenote.standalone.365
com.microsoft.onedrive.standalone
com.microsoft.skypeforbusiness.standalone
com.microsoft.teams.standalone
com.microsoft.teams2.standalone
com.microsoft.intunecompanyportal.standalone
com.microsoft.edge
com.microsoft.defender.standalone
com.microsoft.remotedesktop.standalone
com.microsoft.vscode.zip
com.microsoft.autoupdate.standalone
*)


set strURL to "https://macadmins.software/latest.xml" as text

set coidBaseURLStr to refMe's NSString's stringWithString:(strURL)
set ocidBaseURL to refMe's NSURL's URLWithString:(coidBaseURLStr)

################################################
###### URLRequest部分
################################################
set ocidURLRequest to refMe's NSMutableURLRequest's alloc()'s init()
ocidURLRequest's setHTTPMethod:"GET"
ocidURLRequest's setURL:(ocidBaseURL)
ocidURLRequest's addValue:"application/xml" forHTTPHeaderField:"Content-Type"
###ポストするデータは空
ocidURLRequest's setHTTPBody:(missing value)

################################################
###### データ取得
################################################
set ocidServerResponse to refMe's NSURLConnection's sendSynchronousRequest:(ocidURLRequest) returningResponse:(missing value) |error|:(reference)
###取得
set ocidXMLData to (item 1 of ocidServerResponse)
set listXMLDoc to refMe's NSXMLDocument's alloc()'s initWithData:ocidXMLData options:(refMe's NSXMLDocumentTidyXML) |error|:(reference)

set ocidXMLDoc to item 1 of listXMLDoc
set ocidRootElement to ocidXMLDoc's rootElement()

################################################
###### o365バージョン取得
################################################
repeat with itemRootElement in ocidRootElement's children()
  set strName to itemRootElement's |name|() as text
  if strName is "o365" then
    set ocido365ver to (ocidRootElement's childAtIndex:0)'s stringValue()
  end if
end repeat
#######
log ocido365ver as text

################################################
###### 各アプリケーションのUTI取得
################################################
set ocidPackageArray to ocidRootElement's elementsForName:"package"
repeat with itemackageArray in ocidPackageArray
  set ocidElementID to (itemackageArray's childAtIndex:0)'s stringValue()
log ocidElementID as text
  
end repeat


################################################
###### 対象アプリ最新のバージョン
################################################

set ocidPackageArray to ocidRootElement's elementsForName:"package"
repeat with itemackageArray in ocidPackageArray
  set numCntChild to itemackageArray's childCount() as integer
  set ocidElementID to (itemackageArray's childAtIndex:0)'s stringValue()
  if (ocidElementID as text) is strGetBundleID then
    set ocidCfbundleversionXML to (itemackageArray's childAtIndex:8)'s stringValue()
    set ocidDownloadURL to (itemackageArray's childAtIndex:(numCntChild - 1))'s stringValue()
  end if
end repeat

################################################
###### インストール済みのパージョン
################################################
set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
##バンドルからアプリケーションのURLを取得
set ocidAppBundle to (refMe's NSBundle's bundleWithIdentifier:(strBundleID))
if ocidAppBundle ≠ (missing value) then
  set ocidAppPathURL to ocidAppBundle's bundleURL()
else if ocidAppBundle = (missing value) then
  set ocidAppPathURL to (appSharedWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID))
end if
##予備(アプリケーションのURL)
if ocidAppPathURL = (missing value) then
  tell application "Finder"
    try
      set aliasAppApth to (application file id strBundleID) as alias
      set strAppPath to POSIX path of aliasAppApth as text
      set strAppPathStr to refMe's NSString's stringWithString:(strAppPath)
      set strAppPath to strAppPathStr's stringByStandardizingPath()
      set ocidAppPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(strAppPath) isDirectory:true
    on error
return "アプリケーションが見つかりませんでした"
    end try
  end tell
end if
set ocidFilePathURL to ocidAppPathURL's URLByAppendingPathComponent:("Contents/Info.plist")
#####PLISTの内容を読み込んで
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listReadPlistData to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
set ocidPlistDict to item 1 of listReadPlistData
set ocidCfbundleversionPlist to ocidPlistDict's valueForKey:"CFBundleVersion"
################################################
###### リンク解決
################################################
set strDownloadURL to ocidDownloadURL as text
set strCommandText to ("/usr/bin/curl -Lvs -I -o /dev/null -w '%{url_effective}' " & strDownloadURL & "") as text
set strLocation to (do shell script strCommandText) as text

################################################
###### チェック
################################################
set strCfbundleversionXML to ocidCfbundleversionXML as text
set strCfbundleversionPlist to ocidCfbundleversionPlist as text

if strCfbundleversionXML is strCfbundleversionPlist then
  set strTitle to ("最新版を利用中です") as text
  set strCom to ("最新版を利用中です\r" & strCfbundleversionXML) as text
  set strMes to (strTitle & "\rRSS:" & strCfbundleversionXML & "\rPLIST:" & strCfbundleversionPlist & "\rLink:" & strDownloadURL & "\rLocation:" & strLocation) as text
else
  set strTitle to ("アップデートがあります:" & strCfbundleversionXML) as text
  set strCom to ("アップデートがあります\r最新:" & strCfbundleversionXML & "\r使用中:" & strCfbundleversionPlist) as text
  set strMes to ("最新版ダウンロード:" & strDownloadURL & "\r" & strLocation) as text
end if

################################################
###### ダイアログ
################################################
set appFileManager to refMe's NSFileManager's defaultManager()

####ダイアログに指定アプリのアイコンを表示する
###アイコン名をPLISTから取得
set strIconFileName to (ocidPlistDict's valueForKey:("CFBundleIconFile")) as text
###ICONのURLにして
set strPath to ("Contents/Resources/" & strIconFileName) as text
set ocidIconFilePathURL to ocidAppPathURL's URLByAppendingPathComponent:(strPath) isDirectory:false
###拡張子の有無チェック
set strExtensionName to (ocidIconFilePathURL's pathExtension()) as text
if strExtensionName is "" then
  set ocidIconFilePathURL to ocidIconFilePathURL's URLByAppendingPathExtension:"icns"
end if
##-->これがアイコンパス
log ocidIconFilePathURL's absoluteString() as text
###ICONファイルが実際にあるか?チェック
set boolExists to appFileManager's fileExistsAtPath:(ocidIconFilePathURL's |path|)
###ICONがみつかない時用にデフォルトを用意する
if boolExists is false then
  set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertNoteIcon.icns"
else
  set aliasIconPath to ocidIconFilePathURL's absoluteURL() as alias
  set strIconPath to ocidIconFilePathURL's |path|() as text
end if

set recordResult to (display dialog strCom with title strTitle default answer strMes buttons {"クリップボードにコピー", "終了", "ダウンロード"} default button "ダウンロード" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer)

if button returned of recordResult is "ダウンロード" then
  tell application "Finder"
open location strLocation
  end tell
end if
if button returned of recordResult is "クリップボードにコピー" then
  try
    set strText to text returned of recordResult as text
    ####ペーストボード宣言
    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
    set ocidText to (refMe's NSString's stringWithString:(strText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
  on error
    tell application "Finder"
      set the clipboard to strTitle as text
    end tell
  end try
end if


|

[com.microsoft.teams2]Microsoft Teams (work or school)キャッシュクリア


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
# Microsoft Teams (work or school)のキャッシュ2ゴミ箱
# 先に主要なアプリは終了させてから 
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKIt"
use framework "UniformTypeIdentifiers"
use scripting additions
property refMe : a reference to current application

set strBundleID to ("com.microsoft.teams2") as text


set appFileManager to refMe's NSFileManager's defaultManager()
###
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
#
set ocidContainersDirPathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Containers")
set ocidBundaleDirPathURL to ocidContainersDirPathURL's URLByAppendingPathComponent:(strBundleID)
#
set ocidCachesDirPathURL to ocidBundaleDirPathURL's URLByAppendingPathComponent:("Data/Library/Caches")
set ocidTmpDirPathURL to ocidBundaleDirPathURL's URLByAppendingPathComponent:("Data/tmp")
set ocidWebKitDirPathURL to ocidBundaleDirPathURL's URLByAppendingPathComponent:("Data/Library/WebKit")
set ocidEBWebViewDirPathURL to ocidBundaleDirPathURL's URLByAppendingPathComponent:("Data/Library/Application Support/Microsoft/MSTeams/EBWebView")
#ゴミ箱に入れる
log doMoveToTrash(ocidCachesDirPathURL)
log doMoveToTrash(ocidTmpDirPathURL)
log doMoveToTrash(ocidWebKitDirPathURL)
log doMoveToTrash(ocidEBWebViewDirPathURL)
###################################
########処理 ゴミ箱に入れる
###################################
to doMoveToTrash(argFilePath)
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  #########################################
  ###渡された値のClassを調べてとりあえずNSURLにする
  set refClass to class of argFilePath
  if refClass is list then
return "エラー:リストは処理しません"
  else if refClass is text then
log "テキストパスです"
    set ocidArgFilePathStr to (refMe's NSString's stringWithString:argFilePath)
    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
  else if refClass is alias then
log "エイリアスパスです"
    set strArgFilePath to (POSIX path of argFilePath) as text
    set ocidArgFilePathStr to (refMe's NSString's stringWithString:strArgFilePath)
    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
  else
    set refClass to (className() of argFilePath) as text
    if refClass contains "NSPathStore2" then
log "NSPathStore2です"
      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:argFilePath)
    else if refClass contains "NSCFString" then
log "NSCFStringです"
      set ocidArgFilePath to argFilePath's stringByStandardizingPath
      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
    else if refClass contains "NSURL" then
      set ocidArgFilePathURL to argFilePath
log "NSURLです"
    end if
  end if
  #########################################
  ###
  -->false
  set ocidFalse to (refMe's NSNumber's numberWithBool:false)'s boolValue
  -->true
  set ocidTrue to (refMe's NSNumber's numberWithBool:true)'s boolValue
  #########################################
  ###NSURLがエイリアス実在するか?
  set ocidArgFilePath to ocidArgFilePathURL's |path|()
  set boolFileAlias to appFileManager's fileExistsAtPath:(ocidArgFilePath)
  ###パス先が実在しないなら処理はここまで
  if boolFileAlias = false then
log ocidArgFilePath as text
log "処理中止 パス先が実在しない"
return false
  end if
  #########################################
  ###NSURLがディレクトリなのか?ファイルなのか?
  set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsDirectoryKey) |error|:(reference)
  # log (item 1 of listBoolDir)
  # log (item 2 of listBoolDir)
  # log (item 3 of listBoolDir)
  if (item 2 of listBoolDir) = ocidTrue then
    #########################################
log "ディレクトリです"
log ocidArgFilePathURL's |path| as text
    ##内包リスト
    set listResult to appFileManager's contentsOfDirectoryAtURL:ocidArgFilePathURL includingPropertiesForKeys:{refMe's NSURLPathKey} options:0 |error|:(reference)
    ###結果
    set ocidContentsPathURLArray to item 1 of listResult
    ###リストの数だけ繰り返し
    repeat with itemContentsPathURL in ocidContentsPathURLArray
      ###ゴミ箱に入れる
      set listResult to (appFileManager's trashItemAtURL:itemContentsPathURL resultingItemURL:(missing value) |error|:(reference))
    end repeat
  else
    #########################################
log "ファイルです"
    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsAliasFileKey) |error|:(reference)
    if (item 2 of listBoolDir) = ocidTrue then
log "エイリアスは処理しません"
return false
    end if
    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsSymbolicLinkKey) |error|:(reference)
    if (item 2 of listBoolDir) = ocidTrue then
log "シンボリックリンクは処理しません"
return false
    end if
    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsSystemImmutableKey) |error|:(reference)
    if (item 2 of listBoolDir) = ocidTrue then
log "システムファイルは処理しません"
return false
    end if
    ###ファイルをゴミ箱に入れる
    set listResult to (appFileManager's trashItemAtURL:ocidArgFilePathURL resultingItemURL:(missing value) |error|:(reference))
  end if
return true
end doMoveToTrash



|

[com.microsoft.teams2]Microsoft Teams (work or school)終了


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
# Microsoft Teams (work or school)の関連アプリの強制終了用
# 先に主要なアプリは終了させてから 例えばAcrobatは終了させてから実行
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKIt"
use framework "UniformTypeIdentifiers"
use scripting additions
property refMe : a reference to current application

set listAppBundleID to {"com.microsoft.teams2", "com.microsoft.teams2.modulehost", "com.microsoft.teams2.helper", "com.microsoft.teams2.launcher", "com.microsoft.teams2.notificationcenter", "com.microsoft.teams2.teamsswitcher"} as list


###まずは通常終了 を試みる
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  try
    with timeout of 3 seconds
      tell application id strBundleID to quit
    end timeout
  on error
log "終了出来いORプロセスなし:" & strBundleID
  end try
end repeat
delay 1
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
  repeat with itemAppArray in ocidAppArray
itemAppArray's terminate
  end repeat
end repeat
delay 1
###強制終了
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
  repeat with itemAppArray in ocidAppArray
itemAppArray's forceTerminate
  end repeat
end repeat


###まずは通常終了 を試みる
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  try
    with timeout of 3 seconds
      tell application id strBundleID to quit
    end timeout
  on error
log "終了出来なかった:" & strBundleID
  end try
end repeat
delay 1
###通常終了
log "通常終了開始"
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
  repeat with itemAppArray in ocidAppArray
itemAppArray's terminate
  end repeat
end repeat
delay 1
log "強制終了開始"
###強制終了
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
  repeat with itemAppArray in ocidAppArray
itemAppArray's forceTerminate
  end repeat
end repeat

###
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
  repeat with itemAppArray in ocidAppArray
    set ocidProcess to itemAppArray's processIdentifier()
log ocidProcess
  end repeat
end repeat



###
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
  repeat with itemAppArray in ocidAppArray
    set strPID to itemAppArray's processIdentifier()
    set strCommandText to ("/bin/kill -9 " & strPID & "") as text
do shell script strCommandText
  end repeat
end repeat


|

Msバージョンチェッカーv2(情報を取得できるように変更)


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
(*
com.cocolog-nifty.quicktimer.icefloe
*)
#
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application

###アプリケーションのバンドルID
set strBundleID to "com.microsoft.autoupdate2"

set strGetBundleID to "com.microsoft.autoupdate.standalone" as text
(* インストールパッケージのバンドルID
com.microsoft.office.suite.365
com.microsoft.office.suite.365.businesspro
com.microsoft.word.standalone.365
com.microsoft.excel.standalone.365
com.microsoft.powerpoint.standalone.365
com.microsoft.outlook.standalone.365
com.microsoft.outlook.standalone.365.monthly
com.microsoft.onenote.standalone.365
com.microsoft.onedrive.standalone
com.microsoft.skypeforbusiness.standalone
com.microsoft.teams.standalone
com.microsoft.intunecompanyportal.standalone
com.microsoft.edge
com.microsoft.defender.standalone
com.microsoft.remotedesktop.standalone
com.microsoft.vscode.zip
com.microsoft.autoupdate.standalone
*)


set strURL to "https://macadmins.software/latest.xml" as text

set coidBaseURLStr to refMe's NSString's stringWithString:(strURL)
set ocidBaseURL to refMe's NSURL's URLWithString:(coidBaseURLStr)

################################################
###### URLRequest部分
################################################
set ocidURLRequest to refMe's NSMutableURLRequest's alloc()'s init()
ocidURLRequest's setHTTPMethod:"GET"
ocidURLRequest's setURL:(ocidBaseURL)
ocidURLRequest's addValue:"application/xml" forHTTPHeaderField:"Content-Type"
###ポストするデータは空
ocidURLRequest's setHTTPBody:(missing value)

################################################
###### データ取得
################################################
set ocidServerResponse to refMe's NSURLConnection's sendSynchronousRequest:(ocidURLRequest) returningResponse:(missing value) |error|:(reference)
###取得
set ocidXMLData to (item 1 of ocidServerResponse)
set listXMLDoc to refMe's NSXMLDocument's alloc()'s initWithData:ocidXMLData options:(refMe's NSXMLDocumentTidyXML) |error|:(reference)

set ocidXMLDoc to item 1 of listXMLDoc
set ocidRootElement to ocidXMLDoc's rootElement()

################################################
###### o365バージョン取得
################################################
repeat with itemRootElement in ocidRootElement's children()
  set strName to itemRootElement's |name|() as text
  if strName is "o365" then
    set ocido365ver to (ocidRootElement's childAtIndex:0)'s stringValue()
  end if
end repeat
#######
log ocido365ver as text

################################################
###### 各アプリケーションのUTI取得
################################################
set ocidPackageArray to ocidRootElement's elementsForName:"package"
repeat with itemackageArray in ocidPackageArray
  set ocidElementID to (itemackageArray's childAtIndex:0)'s stringValue()
  log ocidElementID as text
  
end repeat


################################################
###### 対象アプリ最新のバージョン
################################################

set ocidPackageArray to ocidRootElement's elementsForName:"package"
repeat with itemackageArray in ocidPackageArray
  set numCntChild to itemackageArray's childCount() as integer
  set ocidElementID to (itemackageArray's childAtIndex:0)'s stringValue()
  if (ocidElementID as text) is strGetBundleID then
    set ocidCfbundleversionXML to (itemackageArray's childAtIndex:8)'s stringValue()
    set ocidDownloadURL to (itemackageArray's childAtIndex:(numCntChild - 1))'s stringValue()
  end if
end repeat

################################################
###### インストール済みのパージョン
################################################
set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
##バンドルからアプリケーションのURLを取得
set ocidAppBundle to (refMe's NSBundle's bundleWithIdentifier:(strBundleID))
if ocidAppBundle ≠ (missing value) then
  set ocidAppPathURL to ocidAppBundle's bundleURL()
else if ocidAppBundle = (missing value) then
  set ocidAppPathURL to (appSharedWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID))
end if
##予備(アプリケーションのURL)
if ocidAppPathURL = (missing value) then
  tell application "Finder"
    try
      set aliasAppApth to (application file id strBundleID) as alias
      set strAppPath to POSIX path of aliasAppApth as text
      set strAppPathStr to refMe's NSString's stringWithString:(strAppPath)
      set strAppPath to strAppPathStr's stringByStandardizingPath()
      set ocidAppPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(strAppPath) isDirectory:true
    on error
return "アプリケーションが見つかりませんでした"
    end try
  end tell
end if
set ocidFilePathURL to ocidAppPathURL's URLByAppendingPathComponent:("Contents/Info.plist")
#####PLISTの内容を読み込んで
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listReadPlistData to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
set ocidPlistDict to item 1 of listReadPlistData
set ocidCfbundleversionPlist to ocidPlistDict's valueForKey:"CFBundleVersion"
################################################
###### リンク解決
################################################
set strDownloadURL to ocidDownloadURL as text
set strCommandText to ("/usr/bin/curl -Lvs -I -o /dev/null -w '%{url_effective}' " & strDownloadURL & "") as text
set strLocation to (do shell script strCommandText) as text

################################################
###### チェック
################################################
set strCfbundleversionXML to ocidCfbundleversionXML as text
set strCfbundleversionPlist to ocidCfbundleversionPlist as text

if strCfbundleversionXML is strCfbundleversionPlist then
  set strTitle to ("最新版を利用中です") as text
  set strCom to ("最新版を利用中です\r" & strCfbundleversionXML) as text
  set strMes to (strTitle & "\rRSS:" & strCfbundleversionXML & "\rPLIST:" & strCfbundleversionPlist & "\rLink:" & strDownloadURL & "\rLocation:" & strLocation) as text
else
  set strTitle to ("アップデートがあります:" & strCfbundleversionXML) as text
  set strCom to ("アップデートがあります\r最新:" & strCfbundleversionXML & "\r使用中:" & strCfbundleversionPlist) as text
  set strMes to ("最新版ダウンロード:" & strDownloadURL & "\r" & strLocation) as text
end if

################################################
###### ダイアログ
################################################
set appFileManager to refMe's NSFileManager's defaultManager()

####ダイアログに指定アプリのアイコンを表示する
###アイコン名をPLISTから取得
set strIconFileName to (ocidPlistDict's valueForKey:("CFBundleIconFile")) as text
###ICONのURLにして
set strPath to ("Contents/Resources/" & strIconFileName) as text
set ocidIconFilePathURL to ocidAppPathURL's URLByAppendingPathComponent:(strPath) isDirectory:false
###拡張子の有無チェック
set strExtensionName to (ocidIconFilePathURL's pathExtension()) as text
if strExtensionName is "" then
  set ocidIconFilePathURL to ocidIconFilePathURL's URLByAppendingPathExtension:"icns"
end if
##-->これがアイコンパス
log ocidIconFilePathURL's absoluteString() as text
###ICONファイルが実際にあるか?チェック
set boolExists to appFileManager's fileExistsAtPath:(ocidIconFilePathURL's |path|)
###ICONがみつかない時用にデフォルトを用意する
if boolExists is false then
  set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertNoteIcon.icns"
else
  set aliasIconPath to ocidIconFilePathURL's absoluteURL() as alias
  set strIconPath to ocidIconFilePathURL's |path|() as text
end if

set recordResult to (display dialog strCom with title strTitle default answer strMes buttons {"クリップボードにコピー", "終了", "ダウンロード"} default button "ダウンロード" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer)

if button returned of recordResult is "ダウンロード" then
  tell application "Finder"
    open location strLocation
  end tell
end if
if button returned of recordResult is "クリップボードにコピー" then
  try
    set strText to text returned of recordResult as text
    ####ペーストボード宣言
    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
    set ocidText to (refMe's NSString's stringWithString:(strText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
  on error
    tell application "Finder"
      set the clipboard to strTitle as text
    end tell
  end try
end if


|

[Bash]one Driveアップデート 少し修正


【スクリプトエディタで開く】|

#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe

########################################
###管理者インストールしているか?チェック
USER_WHOAMI=$(/usr/bin/whoami)
/bin/echo "実行したユーザーは:$USER_WHOAMI"
if [ "$USER_WHOAMI" != "root" ]; then
  /bin/echo "このスクリプトを実行するには管理者権限が必要です。"
  /bin/echo "sudo で実行してください"
  ### path to me
  SCRIPT_PATH="${BASH_SOURCE[0]}"
  /bin/echo "/usr/bin/sudo \"$SCRIPT_PATH\""
  /bin/echo "↑を実行してください"
  exit 1
else
  ###実行しているユーザー名
  CURRENT_USER=$(/bin/echo "$HOME" | /usr/bin/awk -F'/' '{print $NF}')
  /bin/echo "実行ユーザー:" "$CURRENT_USER"
fi
###コンソールユーザー CONSOLE_USERはFinderでログインしていないと出ない
CONSOLE_USER=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ { print $3 }')
if [ -z "$CONSOLE_USER" ]; then
  /bin/echo "コンソールユーザーが無い=電源入れてログインウィンドウ状態"
else
  /bin/echo "コンソールユーザー:" "$CONSOLE_USER"
fi
########################################
##OS
PLIST_PATH="/System/Library/CoreServices/SystemVersion.plist"
STR_OS_VER=$(/usr/bin/defaults read "$PLIST_PATH" ProductVersion)
/bin/echo "OS VERSION :" "$STR_OS_VER"
STR_MAJOR_VERSION="${STR_OS_VER%%.*}"
/bin/echo "STR_MAJOR_VERSION :" "$STR_MAJOR_VERSION"
STR_MINOR_VERSION="${STR_OS_VER#*.}"
/bin/echo "STR_MINOR_VERSION :" "$STR_MINOR_VERSION"

########################################
###ローカルのユーザーアカウントを取得
TEXT_RESULT=$(/usr/bin/dscl localhost -list /Local/Default/Users PrimaryGroupID | /usr/bin/awk '$2 == 20 { print $1 }')
###リストにする
read -d '\\n' -r -a LIST_USER <<<"$TEXT_RESULT"
###リスト内の項目数
NUM_CNT=${#LIST_USER[@]}
/bin/echo "ユーザー数:" "$NUM_CNT"
########################################
STR_DEVICE_UUID=$(/usr/sbin/ioreg -c IOPlatformExpertDevice | grep IOPlatformUUID | awk -F'"' '{print $4}')
/bin/echo "デバイスUUID: " "$STR_DEVICE_UUID"
###各ユーザーの最終ログアウト日
for ITEM_LIST in "${LIST_USER[@]}"; do
  STR_CHECK_File_PATH="/Users/${ITEM_LIST}/Library/Preferences/ByHost/com.apple.loginwindow.$STR_DEVICE_UUID.plist"
  STR_LAST_LOGOUT=$(/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/stat -f "%Sm" -t "%Y-%m-%d %H:%M:%S" "$STR_CHECK_File_PATH")
  /bin/echo "ユーザー$ITEM_LIST の最終ログアウト日: " "$STR_LAST_LOGOUT"
done
########################################
##デバイス
#起動ディスクの名前を取得する
for ITEM_LIST in "${LIST_USER[@]}"; do
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/diskutil.plist"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/sbin/diskutil info -plist / >"/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/diskutil.plist"
  STARTUPDISK_NAME=$(/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/defaults read "/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/diskutil.plist" VolumeName)
done
/bin/echo "ボリューム名:" "$STARTUPDISK_NAME"
########################################
###ダウンロード起動時に削除する項目
for ITEM_LIST in "${LIST_USER[@]}"; do
  USER_TEMP_DIR=$(/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/mktemp -d)
  /bin/echo "起動時に削除されるディレクトリ:" "$USER_TEMP_DIR"
done
########################################
##基本メンテナンス
########################################
for ITEM_LIST in "${LIST_USER[@]}"; do
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/chmod 700 "/Users/${ITEM_LIST}/Library"
  ##ライブラリの不可視属性を解除
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/chflags nohidden "/Users/${ITEM_LIST}/Library"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/SetFile -a v "/Users/${ITEM_LIST}/Library"
  ## Managed Itemsフォルダを作る
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "/Users/${ITEM_LIST}/Library/Managed Items"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/chmod 755 "/Users/${ITEM_LIST}/Library/Managed Items"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/sbin/chown "${ITEM_LIST}" "/Users/${ITEM_LIST}/Library/Managed Items"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "/Users/${ITEM_LIST}/Library/Managed Items/.localized"
  ##
  /bin/chmod 777 "/Users/${ITEM_LIST}/Library/Caches"
  /bin/chmod 777 /Users/"${ITEM_LIST}"/Library/Caches/*
  ##
  /bin/chmod -Rf 755 "/Users/${ITEM_LIST}/Library/Fonts"
  /usr/sbin/chown -Rf "${ITEM_LIST}" "/Users/${ITEM_LIST}/Library/Fonts"
  ##
  /bin/echo "ライブラリチェックDONE:" "${ITEM_LIST}"
done
########################################
## HOME
########################################
for ITEM_LIST in "${LIST_USER[@]}"; do
  ## Developer
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Developer"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo /usr/sbin/chown "${ITEM_LIST}" "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  ## bin
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/bin"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo /usr/sbin/chown "${ITEM_LIST}" "$STR_CHECK_DIR_PATH"
  ##アクセス権チェック
  /bin/chmod 700 "/Users/${ITEM_LIST}/Movies"
  /bin/chmod 700 /"Users/${ITEM_LIST}/Music"
  /bin/chmod 700 "/Users/${ITEM_LIST}/Pictures"
  /bin/chmod 700 "/Users/${ITEM_LIST}/Downloads"
  /bin/chmod 700 "/Users/${ITEM_LIST}/Documents"
  /bin/chmod 700 "/Users/${ITEM_LIST}/Desktop"
  ##全ローカルユーザーに対して実施したい処理があれば追加する
  /bin/echo "ユーザーディレクトリチェックDONE" "${ITEM_LIST}"
done
########################################
## Public
########################################
for ITEM_LIST in "${LIST_USER[@]}"; do
  /bin/chmod 755 "/Users/${ITEM_LIST}/Public"
  ##
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Drop Box"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 733 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf nobody "$STR_CHECK_DIR_PATH"
  ##########
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Documents"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf admin "$STR_CHECK_DIR_PATH"
  ##
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Downloads"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf admin "$STR_CHECK_DIR_PATH"
  ##
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Favorites"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf admin "$STR_CHECK_DIR_PATH"
  ##########
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Groups"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 770 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf staff "$STR_CHECK_DIR_PATH"
  ##
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Shared"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 750 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf staff "$STR_CHECK_DIR_PATH"
  ##########
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Guest"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 777 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf nobody "$STR_CHECK_DIR_PATH"
  ##
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Shared Items"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 775 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf nobody "$STR_CHECK_DIR_PATH"
  /bin/echo "パブリックチェックDONE" "${ITEM_LIST}"
done
########################################
## Applications
########################################
## Applications
for ITEM_LIST in "${LIST_USER[@]}"; do
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Applications"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  ##サブフォルダを作る
  LIST_SUB_DIR_NAME=("Demos" "Desktop" "Developer" "Documents" "Downloads" "Favorites" "Groups" "Library" "Movies" "Music" "Pictures" "Public" "Shared" "Sites" "System" "Users" "Utilities")
  ##リストの数だけ処理
  for ITEM_DIR_NAME in "${LIST_SUB_DIR_NAME[@]}"; do
    /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH/$ITEM_DIR_NAME"
    /bin/chmod 700 "$STR_CHECK_DIR_PATH/${ITEM_DIR_NAME}"
    /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/$ITEM_DIR_NAME/.localized"
  done
done
########################################
##シンボリックリンクを作る
if [[ ! -e "/Users/$CURRENT_USER/Applications/Applications" ]]; then
  /bin/ln -s "/Applications" "/Users/$CURRENT_USER/Applications/Applications"
fi
if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/Finder Applications" ]]; then
  /bin/ln -s "/System/Library/CoreServices/Finder.app/Contents/Applications" "/Users/$CURRENT_USER/Applications/Utilities/Finder Applications"
fi
if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/Finder Libraries" ]]; then
  /bin/ln -s "/System/Library/CoreServices/Finder.app/Contents/Resources/MyLibraries" "/Users/$CURRENT_USER/Applications/Utilities/Finder Libraries"
fi
if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/System Applications" ]]; then
  /bin/ln -s "/System/Library/CoreServices/Applications" "/Users/$CURRENT_USER/Applications/Utilities/System Applications"
fi
if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/System Utilities" ]]; then
  /bin/ln -s "/Applications/Utilities" "/Users/$CURRENT_USER/Applications/Utilities/System Utilities"
fi





#################################
#インストール基本
#################################

STR_URL="https://go.microsoft.com/fwlink/?linkid=823060"

LOCAL_TMP_DIR=$(/usr/bin/sudo -u "$CURRENT_USER" /usr/bin/mktemp -d)
/bin/echo "TMPDIR:" "$LOCAL_TMP_DIR"

###ファイル名を取得
PKG_FILE_NAME=$(/usr/bin/curl -s -L -I -o /dev/null -w '%{url_effective}' "$STR_URL" | /usr/bin/rev | /usr/bin/cut -d'/' -f1 | /usr/bin/rev)
/bin/echo "PKG_FILE_NAME" "$PKG_FILE_NAME"

###ファイル名指定してダウンロード
/usr/bin/sudo -u "$CURRENT_USER" /usr/bin/curl -L -o "$LOCAL_TMP_DIR/$PKG_FILE_NAME" "$STR_URL" --http1.1 --connect-timeout 20

### インストール(上書き)を実行する
/usr/sbin/installer -pkg "$LOCAL_TMP_DIR/$PKG_FILE_NAME" -target / -dumplog -allowUntrusted -lang ja

exit 0


|

MicrosoftのMacアプリケーション バージョンチェッカー (修正)


【スクリプトエディタで開く】|

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

property refMe : a reference to current application

###アプリケーションのバンドルID
set strBundleID to "com.microsoft.teams"

set strGetBundleID to "com.microsoft.teams.standalone" as text
(* インストールパッケージのバンドルID
com.microsoft.office.suite.365
com.microsoft.office.suite.365.businesspro
com.microsoft.word.standalone.365
com.microsoft.excel.standalone.365
com.microsoft.powerpoint.standalone.365
com.microsoft.outlook.standalone.365
com.microsoft.outlook.standalone.365.monthly
com.microsoft.onenote.standalone.365
com.microsoft.onedrive.standalone
com.microsoft.skypeforbusiness.standalone
com.microsoft.teams.standalone
com.microsoft.intunecompanyportal.standalone
com.microsoft.edge
com.microsoft.defender.standalone
com.microsoft.remotedesktop.standalone
com.microsoft.vscode.zip
com.microsoft.autoupdate.standalone
*)


set strURL to "https://macadmins.software/latest.xml" as text

set coidBaseURLStr to refMe's NSString's stringWithString:(strURL)
set ocidBaseURL to refMe's NSURL's URLWithString:(coidBaseURLStr)

################################################
###### URLRequest部分
################################################
set ocidURLRequest to refMe's NSMutableURLRequest's alloc()'s init()
ocidURLRequest's setHTTPMethod:"GET"
ocidURLRequest's setURL:(ocidBaseURL)
ocidURLRequest's addValue:"application/xml" forHTTPHeaderField:"Content-Type"
###ポストするデータは空
ocidURLRequest's setHTTPBody:(missing value)

################################################
###### データ取得
################################################
set ocidServerResponse to refMe's NSURLConnection's sendSynchronousRequest:(ocidURLRequest) returningResponse:(missing value) |error|:(reference)
###取得
set ocidXMLData to (item 1 of ocidServerResponse)
set listXMLDoc to refMe's NSXMLDocument's alloc()'s initWithData:ocidXMLData options:(refMe's NSXMLDocumentTidyXML) |error|:(reference)

set ocidXMLDoc to item 1 of listXMLDoc
set ocidRootElement to ocidXMLDoc's rootElement()

################################################
###### o365バージョン取得
################################################
repeat with itemRootElement in ocidRootElement's children()
  set strName to itemRootElement's |name|() as text
  if strName is "o365" then
    set ocido365ver to (ocidRootElement's childAtIndex:0)'s stringValue()
  end if
end repeat
#######
log ocido365ver as text

################################################
###### 各アプリケーションのUTI取得
################################################
set ocidPackageArray to ocidRootElement's elementsForName:"package"
repeat with itemackageArray in ocidPackageArray
  set ocidElementID to (itemackageArray's childAtIndex:0)'s stringValue()
  log ocidElementID as text
  
end repeat


################################################
###### 最新のバージョン
################################################

set ocidPackageArray to ocidRootElement's elementsForName:"package"
repeat with itemackageArray in ocidPackageArray
  set ocidElementID to (itemackageArray's childAtIndex:0)'s stringValue()
  if (ocidElementID as text) is strGetBundleID then
    set ocidCfbundleversionXML to (itemackageArray's childAtIndex:8)'s stringValue()
  end if
end repeat
log "RSS:" & ocidCfbundleversionXML as text
################################################
###### インストール済みのパージョン
################################################
set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
##バンドルからアプリケーションのURLを取得
set ocidAppBundle to (refMe's NSBundle's bundleWithIdentifier:(strBundleID))
if ocidAppBundle ≠ (missing value) then
  set ocidAppPathURL to ocidAppBundle's bundleURL()
else if ocidAppBundle = (missing value) then
  set ocidAppPathURL to (appSharedWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID))
end if
##予備(アプリケーションのURL)
if ocidAppPathURL = (missing value) then
  tell application "Finder"
    try
      set aliasAppApth to (application file id strBundleID) as alias
      set strAppPath to POSIX path of aliasAppApth as text
      set strAppPathStr to refMe's NSString's stringWithString:(strAppPath)
      set strAppPath to strAppPathStr's stringByStandardizingPath()
      set ocidAppPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(strAppPath) isDirectory:true
    on error
return "アプリケーションが見つかりませんでした"
    end try
  end tell
end if
set ocidFilePathURL to ocidAppPathURL's URLByAppendingPathComponent:("Contents/Info.plist")
#####PLISTの内容を読み込んで
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listReadPlistData to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
set ocidPlistDict to item 1 of listReadPlistData
set ocidCfbundleversionPlist to ocidPlistDict's valueForKey:"CFBundleVersion"
log "PLIST:" & ocidCfbundleversionPlist as text
################################################
###### チェック
################################################
set intCfbundleversionXML to ocidCfbundleversionXML as integer
set intCfbundleversionPlist to ocidCfbundleversionPlist as integer
if intCfbundleversionXML = intCfbundleversionPlist then
return "最新版を利用中です"
else
return "インストールが必要です"
end if



|

[Office]SaveAsAdobePDF.ppam が読み込めませんでした。(修正版)

SaveAsAdobePDF.ppam が読み込めませんでした。
SaveAsAdobePDF.xlam が読み込めませんでした
linkCreation.dotm が読み込めませんでした 対応用

基本的には『リセットツール』を使えば解決できるのですが

Factory Reset Package
Complete Removal Package
Word Reset Package
Excel Reset Package
PowerPoint Reset Package
Outlook Reset Package
Outlook Data Removal Package
OneNote Reset Package
OneDrive Reset Package
Teams Reset Package
Skype For Business Removal Package
AutoUpdate Reset Package
License Reset Package
Zoom Outlook Plugin Removal Package
WebEx Tools Removal Package

https://office-reset.com/
リセットツールはプラグインを削除はしてくれるが、再インストールはしないので

ダウンロード - movetotrashmsjunk.dmg


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.6"
use framework "Foundation"
use scripting additions


property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()

set listBundleID to {"com.microsoft.Powerpoint", "com.microsoft.Word", "com.microsoft.Excel"} as list


################################
#### Cachesリセット
set strBaseDirPath to "~/Library/Caches"
set ocidBaseDirPathStr to refMe's NSString's stringWithString:(strBaseDirPath)
set ocidBaseDirPath to ocidBaseDirPathStr's stringByStandardizingPath()
repeat with itemBundleID in listBundleID
  set strBundleID to itemBundleID as text
  set ocidGoToTrashDirPath to (ocidBaseDirPath's stringByAppendingPathComponent:(strBundleID))
  set boolDone to doMoveToTrash(ocidGoToTrashDirPath)
  log boolDone as boolean
end repeat
################################
#### plistリセット
set strBaseDirPath to "~/Library/Preferences"
set ocidBaseDirPathStr to refMe's NSString's stringWithString:(strBaseDirPath)
set ocidBaseDirPath to ocidBaseDirPathStr's stringByStandardizingPath()
repeat with itemBundleID in listBundleID
  set strBundleID to itemBundleID as text
  set ocidBaseFilePath to (ocidBaseDirPath's stringByAppendingPathComponent:(strBundleID))
  set ocidGoToTrashDirPath to (ocidBaseFilePath's stringByAppendingPathExtension:("plist"))
  set boolDone to doMoveToTrash(ocidGoToTrashDirPath)
  log boolDone as boolean
end repeat
################################
#### Containersリセット
set strBaseDirPath to "~/Library/Containers"
set ocidBaseDirPathStr to refMe's NSString's stringWithString:(strBaseDirPath)
set ocidBaseDirPath to ocidBaseDirPathStr's stringByStandardizingPath()
repeat with itemBundleID in listBundleID
  set strBundleID to itemBundleID as text
  set ocidGoToTrashDirPath to (ocidBaseDirPath's stringByAppendingPathComponent:(strBundleID))
  set boolDone to doMoveToTrash(ocidGoToTrashDirPath)
  log boolDone as boolean
end repeat
################################
#### Application Scriptsリセット
set strBaseDirPath to "~/Library/Application Scripts"
set ocidBaseDirPathStr to refMe's NSString's stringWithString:(strBaseDirPath)
set ocidBaseDirPath to ocidBaseDirPathStr's stringByStandardizingPath()
repeat with itemBundleID in listBundleID
  set strBundleID to itemBundleID as text
  set ocidGoToTrashDirPath to (ocidBaseDirPath's stringByAppendingPathComponent:(strBundleID))
  set boolDone to doMoveToTrash(ocidGoToTrashDirPath)
  log boolDone as boolean
end repeat

################################
#### temporaryDirectory T リセット
set ocidTemporaryDirPathURL to appFileManager's temporaryDirectory
repeat with itemBundleID in listBundleID
  set strBundleID to itemBundleID as text
  set ocidGoToTrashDirPathURL to (ocidTemporaryDirPathURL's URLByAppendingPathComponent:(strBundleID))
  set boolDone to doMoveToTrash(ocidGoToTrashDirPathURL)
  log boolDone as boolean
end repeat

################################
#### temporaryDirectory C リセット
set ocidTemporaryDirPathURL to appFileManager's temporaryDirectory
set ocidContainerDirPathURL to ocidTemporaryDirPathURL's URLByDeletingLastPathComponent()
set ocidCPathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:"C"
repeat with itemBundleID in listBundleID
  set strBundleID to itemBundleID as text
  set ocidGoToTrashDirPathURL to (ocidCPathURL's URLByAppendingPathComponent:(strBundleID))
  set boolDone to doMoveToTrash(ocidGoToTrashDirPathURL)
  log boolDone as boolean
end repeat


################################
###Startup.localized クリーニング
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Word/~$nkCreation.dotm"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)

set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Excel/~$SaveAsAdobePDF.xlam"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)


set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Powerpoint/~$SaveAsAdobePDF.ppam"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)

################################
###Startup.localized クリーニング
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Word/nkCreation.dotm"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)

set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Excel/SaveAsAdobePDF.xlam"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)


set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Powerpoint/SaveAsAdobePDF.ppam"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)



################################
####Add-Ins.localized クリーニング
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Add-Ins.localized/Word/~$nkCreation.dotm"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)

set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Add-Ins.localized/Excel/~$SaveAsAdobePDF.xlam"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)

set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Add-Ins.localized/Powerpoint/~$SaveAsAdobePDF.ppam"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)
################################

set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/mip_policy"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set boolDone to doMoveToTrash(ocidFilePath)
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/FontCache"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set boolDone to doMoveToTrash(ocidFilePath)
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/ComRPC32"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set boolDone to doMoveToTrash(ocidFilePath)
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/TemporaryItems"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set boolDone to doMoveToTrash(ocidFilePath)
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/MicrosoftRegistrationDB.reg"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set boolDone to doMoveToTrash(ocidFilePath)
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/Microsoft Office ACL [English]"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set boolDone to doMoveToTrash(ocidFilePath)

####新しいファイルをコピーする

set ocidUserShotName to refMe's NSUserName()
set strUserName to ocidUserShotName as text

set strDtomFilePath to "/Library/Application Support/Adobe/MACPDFM/DC/linkCreation.dotm"
set strPpamFilePath to "/Library/Application Support/Adobe/MACPDFM/DC/SaveAsAdobePDF.ppam"
set strXlamFilePath to "/Library/Application Support/Adobe/MACPDFM/DC/SaveAsAdobePDF.xlam"

set strDistDtomFilePath to "/Users/" & strUserName & "/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Word/linkCreation.dotm"
set strDistPpamFilePath to "/Users/" & strUserName & "/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Powerpoint/SaveAsAdobePDF.ppam"
set strDistXlamFilePath to "/Users/" & strUserName & "/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Excel/SaveAsAdobePDF.xlam"


set strCommandText to ("/usr/bin/ditto \"" & strDtomFilePath & "\" \"" & strDistDtomFilePath & "\"") as text
do shell script strCommandText
set strCommandText to ("/usr/bin/ditto \"" & strPpamFilePath & "\" \"" & strDistPpamFilePath & "\"") as text
do shell script strCommandText
set strCommandText to ("/usr/bin/ditto \"" & strXlamFilePath & "\" \"" & strDistXlamFilePath & "\"") as text
do shell script strCommandText

set strCommandText to ("/bin/chmod 755 \"" & strDistDtomFilePath & "\"") as text
do shell script strCommandText
set strCommandText to ("/bin/chmod 755 \"" & strDistPpamFilePath & "\"") as text
do shell script strCommandText
set strCommandText to ("/bin/chmod 755 \"" & strDistXlamFilePath & "\"") as text
do shell script strCommandText



################################
####User Content.localizedを開く
set strDirFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized"
set ocidFilePathStr to refMe's NSString's stringWithString:(strDirFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:true
set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
appShardWorkspace's openURL:ocidFilePathURL

################################
####ゴミ箱に入れるサブ
to doMoveToTrash(argFilePath)
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  #########################################
  ###渡された値のClassを調べてとりあえずNSURLにする
  set refClass to class of argFilePath
  if refClass is list then
return "エラーリストは処理しません"
  else if refClass is text then
    log "テキストパスです"
    set ocidArgFilePathStr to (refMe's NSString's stringWithString:argFilePath)
    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
  else if refClass is alias then
    log "エイリアスパスです"
    set strArgFilePath to (POSIX path of argFilePath) as text
    set ocidArgFilePathStr to (refMe's NSString's stringWithString:strArgFilePath)
    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
  else
    set refClass to (className() of argFilePath) as text
    if refClass contains "NSPathStore2" then
      log "NSPathStore2です"
      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:argFilePath)
    else if refClass contains "NSCFString" then
      log "NSCFStringです"
      set ocidArgFilePath to argFilePath's stringByStandardizingPath
      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
    else if refClass contains "NSURL" then
      set ocidArgFilePathURL to argFilePath
      log "NSURLです"
    end if
  end if
  #########################################
  ###
  -->false
  set ocidFalse to (refMe's NSNumber's numberWithBool:false)'s boolValue
  -->true
  set ocidTrue to (refMe's NSNumber's numberWithBool:true)'s boolValue
  #########################################
  ###NSURLがエイリアス実在するか?
  set ocidArgFilePath to ocidArgFilePathURL's |path|()
  set boolFileAlias to appFileManager's fileExistsAtPath:(ocidArgFilePath)
  log ocidArgFilePath as text
  ###パス先が実在しないなら処理はここまで
  if boolFileAlias = false then
    log "処理中止"
return false
  end if
  #########################################
  ###NSURLがディレクトリなのか?ファイルなのか?
  set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsDirectoryKey) |error|:(reference)
  if (item 2 of listBoolDir) = ocidTrue then
    #########################################
    log "ディレクトリです"
    ##内包リスト
    set listResult to appFileManager's contentsOfDirectoryAtURL:ocidArgFilePathURL includingPropertiesForKeys:{refMe's NSURLPathKey} options:0 |error|:(reference)
    ###結果
    set ocidContentsPathURLArray to item 1 of listResult
    ###リストの数だけ繰り返し
    repeat with itemContentsPathURL in ocidContentsPathURLArray
      ###ゴミ箱に入れる
      set listResult to (appFileManager's trashItemAtURL:itemContentsPathURL resultingItemURL:(missing value) |error|:(reference))
    end repeat
  else
    #########################################
    log "ファイルです"
    ###念のためFilderでも調べる
    tell application "Finder"
      set aliasArgFilePath to ocidArgFilePathURL as alias
      set strPathKind to (kind of aliasArgFilePath) as text
    end tell
    ###/tmpのような特殊フォルダの場合は処理しない
    if strPathKind is "フォルダ" then
return "特殊ディレクトリかシンボリックリンクなので処理しません"
    else
      ###ファイルをゴミ箱に入れる
      set listResult to (appFileManager's trashItemAtURL:ocidArgFilePathURL resultingItemURL:(missing value) |error|:(reference))
    end if
  end if
return true
end doMoveToTrash

|

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat Dialog Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ Acrobat Stamps Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin System Information Admin Tools Admin Users Admin Volumes Adobe Apple AppleScript AppleScript Guide AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Automator AppleScript AVAsset AppleScript AVconvert AppleScript AVFoundation AppleScript AVURLAsset AppleScript BackUp AppleScript Barcode AppleScript Bash AppleScript Basic AppleScript Basic Path AppleScript Bluetooth AppleScript BOX AppleScript Browser AppleScript Calendar AppleScript CD/DVD AppleScript Choose AppleScript Chrome AppleScript CIImage AppleScript CloudStorage AppleScript Color AppleScript com.apple.LaunchServices.OpenWith AppleScript Console AppleScript Contacts AppleScript CotEditor AppleScript CURL AppleScript current application AppleScript Date&Time AppleScript delimiters AppleScript Desktop AppleScript Device AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript eMail AppleScript Encode Decode AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript HTML AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim Applescript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mobileconfig AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSBitmapImageRep AppleScript NSBundle AppleScript NSCFBoolean AppleScript NSCharacterSet AppleScript NSColor AppleScript NSColorList AppleScript NSData AppleScript NSDictionary AppleScript NSError AppleScript NSEvent AppleScript NSFileAttributes AppleScript NSFileManager AppleScript NSFont AppleScript NSFontManager AppleScript NSImage AppleScript NSIndex AppleScript NSKeyedArchiver AppleScript NSKeyedUnarchiver AppleScript NSLocale AppleScript NSMutableArray AppleScript NSMutableDictionary AppleScript NSMutableString AppleScript NSNotFound AppleScript NSNumber AppleScript NSOpenPanel AppleScript NSPasteboard AppleScript NSPDFImageRep AppleScript NSpoint AppleScript NSPredicate AppleScript NSRange AppleScript NSRegularExpression AppleScript NSRunningApplication AppleScript NSScreen AppleScript NSSize AppleScript NSString AppleScript NSStringCompareOptions AppleScript NSTask AppleScript NSTimeZone AppleScript NSURL AppleScript NSURL File AppleScript NSURLBookmark AppleScript NSURLComponents AppleScript NSURLResourceKey AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photos AppleScript Photoshop AppleScript Plist System Events AppleScript PostScript AppleScript prefPane AppleScript Preview AppleScript Python AppleScript QR AppleScript QR Decode AppleScript QuickLook AppleScript QuickTime AppleScript record AppleScript Regular Expression AppleScript Reminders AppleScript ReName AppleScript Repeat AppleScript RTF AppleScript Safari AppleScript SaveFile AppleScript ScreenCapture AppleScript ScreenSaver AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript Sort AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript System Events AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text TSV AppleScript TextEdit AppleScript Translate AppleScript Trash AppleScript Twitter AppleScript UI AppleScript Unit Conversion AppleScript UTType AppleScript valueForKeyPath AppleScript Video AppleScript VisionKit AppleScript Visual Studio Code AppleScript webarchive AppleScript webp AppleScript Wifi AppleScript XML AppleScript XML EPUB AppleScript XML OPML AppleScript XML Plist AppleScript XML RSS AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript YouTube AppleScript Zero Suppress Applications Barcode OnLine Tools CityCode Design iPhone List Logs lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom zoom