

【スクリプトエディタで開く】 |
ChromeのAIモデルのバイナリーをゴミ箱に入れる.scpt.scpt | ソース |
|---|
| 001 | #!/usr/bin/env osascript |
| 002 | #coding: utf-8 |
| 003 | ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-- |
| 004 | (* |
| 005 |
|
| 006 | Google ChromeのAIモデルのバイナリーをゴミ箱に入れる |
| 007 | ダウンロードフォルダをロックすることで |
| 008 | ダウンロードさせないようにします |
| 009 |
|
| 010 | com.cocolog-nifty.quicktimer.icefloe *) |
| 011 | ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-- |
| 012 | use AppleScript version "2.8" |
| 013 | use framework "Foundation" |
| 014 | use framework "AppKit" |
| 015 | use framework "UniformTypeIdentifiers" |
| 016 | use scripting additions |
| 017 |
|
| 018 | property refMe : a reference to current application |
| 019 |
|
| 020 |
|
| 021 | set listDirPath to {"~/Library/Application Support/Google/Chrome/OnDeviceHeadSuggestModel", "~/Library/Application Support/Google/Chrome/OptGuideOnDeviceModel", "~/Library/Application Support/Google/Chrome/OptimizationHints", "~/Library/Application Support/Google/Chrome/optimization_guide_model_store"} as list |
| 022 |
|
| 023 | repeat with itemDirPath in listDirPath |
| 024 | #URLにして |
| 025 | set strDirPath to itemDirPath as text |
| 026 | set ocidDirPathStr to (refMe's NSString's stringWithString:(strDirPath)) |
| 027 | set ocidDirPath to ocidDirPathStr's stringByStandardizingPath() |
| 028 | set ocidDirPath to ocidDirPath's stringByExpandingTildeInPath() |
| 029 | set ocidDirPathURL to (refMe's NSURL's fileURLWithPath:(ocidDirPath) isDirectory:(true)) |
| 030 | #まずフォルダを作って |
| 031 | set appFileManager to refMe's NSFileManager's defaultManager() |
| 032 | set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s init() |
| 033 | (ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions)) |
| 034 | set listDone to (appFileManager's createDirectoryAtURL:(ocidDirPathURL) withIntermediateDirectories:(true) attributes:(ocidAttrDict) |error|:(reference)) |
| 035 | #ゴミ箱に入れる |
| 036 | set listDone to (appFileManager's trashItemAtURL:(ocidDirPathURL) resultingItemURL:(ocidDirPathURL) |error|:(reference)) |
| 037 | #フォルダを作って |
| 038 | set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s init() |
| 039 | (ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions)) |
| 040 | set listDone to (appFileManager's createDirectoryAtURL:(ocidDirPathURL) withIntermediateDirectories:(true) attributes:(ocidAttrDict) |error|:(reference)) |
| 041 | |
| 042 | #書き込み出来なくする |
| 043 | set appFileManager to refMe's NSFileManager's defaultManager() |
| 044 | set listDone to (ocidDirPathURL's setResourceValue:(true) forKey:(refMe's NSURLIsUserImmutableKey) |error|:(reference)) |
| 045 | |
| 046 | |
| 047 | end repeat |
| AppleScriptで生成しました |
|---|