« [DaVinci Resolve]字幕を使ってチャプタを指定する | トップページ | [BASH]RSSの取得と表示(yahoo.news) »

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



|

« [DaVinci Resolve]字幕を使ってチャプタを指定する | トップページ | [BASH]RSSの取得と表示(yahoo.news) »

AppleScript Microsoft」カテゴリの記事