Adobe Fonts 同期のリセット(同期不具合発生時用) 少し手直し
AppleScript サンプルコード
行番号 | ソース |
---|---|
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | # |
004 | # Adobeフォントリストファイル 拡張子lstもゴミ箱に入れるようにした |
005 | # |
006 | # |
007 | # com.cocolog-nifty.quicktimer.icefloe |
008 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
009 | use AppleScript version "2.8" |
010 | use framework "Foundation" |
011 | use framework "AppKit" |
012 | use scripting additions |
013 | |
014 | property refMe : a reference to current application |
015 | |
016 | set appFileManager to refMe's NSFileManager's defaultManager() |
017 | |
018 | ################################### |
019 | #まずは処理するアプリケーションを終了させる |
020 | ################################### |
021 | set strKeyWord to ("adobe") as text |
022 | log "アプリケーション終了開始" |
023 | set numCntApp to 1 |
024 | repeat until numCntApp = 0 |
025 | ##対象プロセスが無くなるまで繰り返し |
026 | set numCntApp to doAppQuit(strKeyWord) |
027 | delay 1 |
028 | end repeat |
029 | log "アプリケーション終了" |
030 | ################################### |
031 | #プロセス終了を確認する |
032 | ################################### |
033 | log "プロセス終了開始" |
034 | log doKillProcess() |
035 | |
036 | log "プロセス終了" |
037 | ################################### |
038 | #フォントのキャッシュを ゴミ箱に入れる |
039 | ################################### |
040 | |
041 | log doMoveToTrash("~/Library/Application Support/Adobe/CoreSync/plugins/livetype") |
042 | |
043 | ################################### |
044 | #フォントのキャッシュを ゴミ箱に入れる |
045 | ################################### |
046 | set appFileManager to refMe's NSFileManager's defaultManager() |
047 | set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask)) |
048 | set ocidApplicatioocidupportDirPathURL to ocidURLsArray's firstObject() |
049 | # |
050 | set ocidTargetDirPathURL to ocidApplicatioocidupportDirPathURL's URLByAppendingPathComponent:("Adobe") isDirectory:(true) |
051 | #コンテンツの収集 |
052 | set ocidPropertiesArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0) |
053 | ocidPropertiesArray's addObject:(refMe's NSURLIsDirectoryKey) |
054 | ocidPropertiesArray's addObject:(refMe's NSURLNameKey) |
055 | ocidPropertiesArray's addObject:(refMe's NSURLPathKey) |
056 | set ocidOption to (refMe's NSDirectoryEnumerationSkipsHiddenFiles) |
057 | #収集 |
058 | set ocidEmuDict to appFileManager's enumeratorAtURL:(ocidTargetDirPathURL) includingPropertiesForKeys:(ocidPropertiesArray) options:(ocidOption) errorHandler:(reference) |
059 | #全部のパスを順番に調べる |
060 | repeat |
061 | #次へ |
062 | set ocidItemURL to ocidEmuDict's nextObject() |
063 | #空になったらループ終了 |
064 | if ocidItemURL = (missing value) then |
065 | exit repeat |
066 | else |
067 | #ファイルか?それ以外か? |
068 | set listResponse to (ocidItemURL's getResourceValue:(reference) forKey:(refMe's NSURLIsRegularFileKey) |error| :(reference)) |
069 | set boolFile to (item 2 of listResponse) as boolean |
070 | if boolFile is true then |
071 | #ファイルなら |
072 | set strExtensionName to ocidItemURL's pathExtension() as text |
073 | if strExtensionName is "lst" then |
074 | #拡張子がlstなら |
075 | set strFileName to ocidItemURL's lastPathComponent() as text |
076 | if strFileName contains "Fnt" then |
077 | #ファイル名にFNTが含まれているなら |
078 | #ゴミ箱に入れる |
079 | set listDone to (appFileManager's trashItemAtURL:(ocidItemURL) resultingItemURL:(ocidItemURL) |error| :(reference)) |
080 | if (item 2 of listDone) ≠ (missing value) then |
081 | set strErrorNO to (item 2 of listDone)'s code() as text |
082 | set strErrorMes to (item 2 of listDone)'s localizedDescription() as text |
083 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
084 | return "エラーしました" & strErrorNO & strErrorMes |
085 | end if |
086 | end if |
087 | end if |
088 | end if |
089 | end if |
090 | |
091 | end repeat |
092 | |
093 | |
094 | ################################### |
095 | #処理 ゴミ箱に入れる |
096 | ################################### |
097 | |
098 | to doMoveToTrash(argFilePath) |
099 | ###ファイルマネジャー初期化 |
100 | set appFileManager to refMe's NSFileManager's defaultManager() |
101 | ######################################### |
102 | ###渡された値のClassを調べてとりあえずNSURLにする |
103 | set refClass to class of argFilePath |
104 | if refClass is list then |
105 | return "エラー:リストは処理しません" |
106 | else if refClass is text then |
107 | log "テキストパスです" |
108 | set ocidArgFilePathStr to (refMe's NSString's stringWithString:argFilePath) |
109 | set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath |
110 | set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath) |
111 | else if refClass is alias then |
112 | log "エイリアスパスです" |
113 | set strArgFilePath to (POSIX path of argFilePath) as text |
114 | set ocidArgFilePathStr to (refMe's NSString's stringWithString:strArgFilePath) |
115 | set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath |
116 | set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath) |
117 | else |
118 | set refClass to (className() of argFilePath) as text |
119 | if refClass contains "NSPathStore2" then |
120 | log "NSPathStore2です" |
121 | set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:argFilePath) |
122 | else if refClass contains "NSCFString" then |
123 | log "NSCFStringです" |
124 | set ocidArgFilePath to argFilePath's stringByStandardizingPath |
125 | set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath) |
126 | else if refClass contains "NSURL" then |
127 | set ocidArgFilePathURL to argFilePath |
128 | log "NSURLです" |
129 | end if |
130 | end if |
131 | ######################################### |
132 | ### |
133 | -->false |
134 | set ocidFalse to (refMe's NSNumber's numberWithBool:false)'s boolValue |
135 | -->true |
136 | set ocidTrue to (refMe's NSNumber's numberWithBool:true)'s boolValue |
137 | ######################################### |
138 | ###NSURLがエイリアス実在するか? |
139 | set ocidArgFilePath to ocidArgFilePathURL's |path|() |
140 | set boolFileAlias to appFileManager's fileExistsAtPath:(ocidArgFilePath) |
141 | ###パス先が実在しないなら処理はここまで |
142 | if boolFileAlias = false then |
143 | log ocidArgFilePath as text |
144 | log "処理中止 パス先が実在しない" |
145 | return false |
146 | end if |
147 | ######################################### |
148 | ###NSURLがディレクトリなのか?ファイルなのか? |
149 | set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsDirectoryKey) |error| :(reference) |
150 | # log (item 1 of listBoolDir) |
151 | # log (item 2 of listBoolDir) |
152 | # log (item 3 of listBoolDir) |
153 | if (item 2 of listBoolDir) = ocidTrue then |
154 | ######################################### |
155 | log "ディレクトリです" |
156 | log ocidArgFilePathURL's |path| as text |
157 | ##内包リスト |
158 | set listResult to appFileManager's contentsOfDirectoryAtURL:ocidArgFilePathURL includingPropertiesForKeys:{refMe's NSURLPathKey} options:0 |error| :(reference) |
159 | ###結果 |
160 | set ocidContentsPathURLArray to item 1 of listResult |
161 | ###リストの数だけ繰り返し |
162 | repeat with itemContentsPathURL in ocidContentsPathURLArray |
163 | ###ゴミ箱に入れる |
164 | set listResult to (appFileManager's trashItemAtURL:itemContentsPathURL resultingItemURL:(missing value) |error| :(reference)) |
165 | end repeat |
166 | else |
167 | ######################################### |
168 | log "ファイルです" |
169 | set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsAliasFileKey) |error| :(reference) |
170 | if (item 2 of listBoolDir) = ocidTrue then |
171 | log "エイリアスは処理しません" |
172 | return false |
173 | end if |
174 | set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsSymbolicLinkKey) |error| :(reference) |
175 | if (item 2 of listBoolDir) = ocidTrue then |
176 | log "シンボリックリンクは処理しません" |
177 | return false |
178 | end if |
179 | set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsSystemImmutableKey) |error| :(reference) |
180 | if (item 2 of listBoolDir) = ocidTrue then |
181 | log "システムファイルは処理しません" |
182 | return false |
183 | end if |
184 | ###ファイルをゴミ箱に入れる |
185 | set listResult to (appFileManager's trashItemAtURL:ocidArgFilePathURL resultingItemURL:(missing value) |error| :(reference)) |
186 | end if |
187 | return true |
188 | end doMoveToTrash |
189 | |
190 | |
191 | |
192 | |
193 | ############################# |
194 | #アプリケーション終了簡易版 |
195 | ############################# |
196 | to doAppQuit(argKeyWord) |
197 | #全プロセス取得して |
198 | tell application "System Events" |
199 | #バンドルIDリストにします |
200 | set listBundleID to bundle identifier of (every application process) |
201 | end tell |
202 | #全プロセスで |
203 | repeat with itemBundleID in listBundleID |
204 | #対象のドメイン名を含むなら |
205 | if itemBundleID contains argKeyWord then |
206 | #バンドルIDでアプリケーションを取得して |
207 | set ocidResultsArray to (refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:(itemBundleID)) |
208 | set numCntArray to ocidResultsArray's |count|() |
209 | repeat with itemNo from 0 to (numCntArray - 1) by 1 |
210 | set ocidRunApp to (ocidResultsArray's objectAtIndex:(itemNo)) |
211 | #通常終了を試みます |
212 | set boolDone to ocidRunApp's terminate() |
213 | if (boolDone) is true then |
214 | log itemBundleID & ":正常終了" |
215 | #失敗したら |
216 | else if (boolDone) is false then |
217 | #強制終了を試みます |
218 | set boolDone to ocidRunApp's forceTerminate() |
219 | if (boolDone) is true then |
220 | log itemBundleID & ":強制終了" |
221 | else if (boolDone) is false then |
222 | log itemBundleID & ":終了出来ませんでした" |
223 | end if |
224 | end if |
225 | end repeat |
226 | end if |
227 | end repeat |
228 | #実行後のプロセス数で |
229 | tell application "System Events" |
230 | set listBundleID to bundle identifier of (every application process) |
231 | end tell |
232 | set numDoneCnt to 0 as integer |
233 | repeat with itemBundleID in listBundleID |
234 | #対象のドメイン名を含む数を |
235 | if itemBundleID contains "adobe" then |
236 | set numDoneCnt to numDoneCnt + 1 |
237 | end if |
238 | end repeat |
239 | #戻す |
240 | return numDoneCnt |
241 | end doAppQuit |
242 | |
243 | ################################### |
244 | #プロセス終了を確認する |
245 | ################################### |
246 | to doKillProcess() |
247 | set listAppName to {"ACCFinderSync", "AGMService", "AcroCEF", "AcroCEF Helper", "AcroCEF Helper (GPU)", "AcroCEF Helper (Renderer)", "Acrobat", "Acrobat CEF", "Acrobat CEF Helper", "Acrobat CEF Helper (GPU)", "Acrobat CEF Helper (Renderer)", "Adobe Acrobat Synchronizer", "Adobe CEF", "Adobe CEF Helper", "Adobe CEF Helper (GPU)", "Adobe CEF Helper (Renderer)", "Adobe Content Synchronizer", "Adobe Crash Handler", "Adobe Crash Processor", "Adobe Crash Reporter", "Adobe Desktop Service", "Adobe FormsCentral", "Adobe Installer", "AdobeCEF", "AdobeCEF Helper", "AdobeCEF Helper (GPU)", "AdobeCEF Helper (Renderer)", "AdobeCRDaemon", "AdobeExtensionsService", "AdobeGCClient", "AdobeIPCBroker", "AdobeReader", "AdobeResourceSynchronizer", "CCLibrary", "CCXProcess", "Core Sync", "Core Sync Helper", "Creative Cloud", "Creative Cloud Content Manager.node", "Creative Cloud Helper", "LogTransport", "RdrCEF", "RdrCEF Helper", "RdrCEF Helper (GPU)", "RdrCEF Helper (Renderer)", "Reader CEF", "Reader CEF Helper", "Reader CEF Helper (GPU)", "Reader CEF Helper (Renderer)", "armsvc", "com.adobe.ARMDC.Communicator", "com.adobe.ARMDC.SMJobBlessHelper", "com.adobe.acc.installer.v2"} as list |
248 | |
249 | |
250 | repeat with itemAppName in listAppName |
251 | set strAppName to itemAppName as text |
252 | set strCommandText to "/bin/ps -alxe | grep \"" & strAppName & "\" | grep -v \"grep\" | awk '{ print $2 }'" as text |
253 | set strResponce to (do shell script strCommandText) as text |
254 | log strResponce |
255 | set AppleScript's text item delimiters to "\r" |
256 | set listPID to every text item of strResponce |
257 | set AppleScript's text item delimiters to "" |
258 | |
259 | if (count of listPID) = 0 then |
260 | log "対象プロセス無し" |
261 | else |
262 | repeat with itemPID in listPID |
263 | ###プロセスを終了させる |
264 | doQuitApp2PID(itemPID) |
265 | end repeat |
266 | end if |
267 | end repeat |
268 | |
269 | end doKillProcess |
270 | |
271 | |
272 | |
273 | |
274 | ################################### |
275 | #アプリケーションを終了させる |
276 | ################################### |
277 | to doQuitApp2PID(argPID) |
278 | set strPID to argPID as text |
279 | #### killallを使う場合 |
280 | set strCommandText to ("/bin/kill -15 " & strPID & "") as text |
281 | set ocidCommandText to refMe's NSString's stringWithString:strCommandText |
282 | set ocidTermTask to refMe's NSTask's alloc()'s init() |
283 | ocidTermTask's setLaunchPath:"/bin/zsh" |
284 | ocidTermTask's setArguments:({"-c", ocidCommandText}) |
285 | set listResults to ocidTermTask's launchAndReturnError:(reference) |
286 | log listResults |
287 | if item 1 of listResults is true then |
288 | log "正常終了" |
289 | else |
290 | try |
291 | set strCommandText to ("/bin/kill -9 " & strPID & "") as text |
292 | set strResponse to (do shell script strCommandText) as text |
293 | end try |
294 | end if |
295 | end doQuitApp2PID |
296 | |
AppleScriptで生成しました |
| 固定リンク
« [com.adobe.ARMDC]アクロバット・リフレッシュマネージャー Acrobat Refresh Manager の停止(少し改良) | トップページ | IPアドレスを10進数に変換する »
「Adobe Fonts」カテゴリの記事
- Adobe Font トラブル対応(2025.01.14)
- Adobe Fonts 同期のリセット(プロセスの終了を改善)v3(2025.01.13)
- AdobeFontsの同期中のフォント一覧を出力する(HTML形式)色々詰め込んだ修正版(2024.12.26)
- AdobeFontsの同期中のフォント一覧を出力する(TSVタブ区切りテキスト形式)少し修正(2024.12.24)
- AdobeFontsの同期中のフォント一覧を出力する(HTML形式)少し修正(2024.12.24)