« [TextEdit]行番号を入れる | トップページ | [TextEdit]新規ファイルをFinderで作っておいて… »

[Edge]アップデートフォルダを削除

あぁこれ自分用
Edgeのアップデートフォルダをそのままにしておくと
アプリケーションがバージョン違いで複数ある事になって面倒
1:EdgeUpdaterの有無
◆:↑のフォルダがあれば処理
2:EdgeUpdaterの中のバージョンを調べて
◆:バージョンが同じなら削除
→バージョンが同じ=バージョンアップ済みと判断


#!/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 objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSJSONSerialization : a reference to objMe's NSJSONSerialization
property objNSUTF8StringEncoding : a reference to objMe's NSUTF8StringEncoding


tell application "Finder"
set aliasApplicationSupportDir to path to application support from user domain
try
set aliasUpDateDir to folder "EdgeUpdater" of folder "Microsoft" of folder aliasApplicationSupportDir as alias
on error
return "アップデートフォルダがありません"
end try
set starUpDateDir to POSIX path of aliasUpDateDir as text
set boolDirExist to (exists of folder aliasUpDateDir)
end tell
if boolDirExist is true then
tell application "Finder"
every folder of aliasUpDateDir
set strOpenFilePath to ("" & starUpDateDir & "prefs.json") as text
set aliasJsonFile to POSIX file strOpenFilePath as alias
end tell
else
return
end if

open for access aliasJsonFile
set strJsonData to (read aliasJsonFile) as text
close access aliasJsonFile
log strJsonData
set objStrNSStringJson to (objNSString's stringWithString:strJsonData)'s dataUsingEncoding:(objMe's NSUTF8StringEncoding)
set recordJson to (objNSJSONSerialization's JSONObjectWithData:(objStrNSStringJson) options:0 |error|:(missing value)) as record

set updaterNo to pv of |msedge-updater| of apps of updateclientdata of recordJson
set stableNo to pv of |msedge-stable| of apps of updateclientdata of recordJson

tell application "Finder"
set aliasAppPath to application file id "com.microsoft.edgemac" as alias
set strAppPath to POSIX path of aliasAppPath
end tell
set strPlistPath to ("" & strAppPath & "Contents/Info.plist") as text

###Rootの構造を調べます
tell application "System Events"
tell property list file strPlistPath
tell property list item "CFBundleVersion"
set strVersion to value as text
end tell
end tell
end tell

if strVersion is stableNo then
tell application "Finder"
move folder aliasUpDateDir to trash
end tell
end if

|

« [TextEdit]行番号を入れる | トップページ | [TextEdit]新規ファイルをFinderで作っておいて… »

AppleScript Microsoft」カテゴリの記事