Mac内のアプリケーションを探してリスト化 [AppleScript辞書はつくれるか?]
set limiter to 100 --探すフォルダ数が多いほど深くまで探します (100:約5秒・500:約40秒・1000:約90秒) -- limiterは、100もあれば主要なのが調べられる。1200もあれば全部調べられると思います set addressPath to true -- 絶対パス(true) / アプリケーション名のみ(false)
-- main set applicationsFolder to (path to (applications folder)) as text --|アプリケーションフォルダ| set userApplications to ((path to home folder) as text) & "Applications" --|ユーザー内のアプリケーションフォルダ| set downloadApplications to ((path to home folder) as text) & "Downloads" --|ユーザー内のダウンロードフォルダ|
set aTime to current date set searchFolder to {applicationsFolder, downloadApplications} try tell application "Finder" to get name of folder userApplications set searchFolder to searchFolder & userApplications end try set applicationList to "" set n to 0 set l to 0 tell application "Finder" repeat limiter times
set n to n + 1 if (n mod 20) = 0 then log {n, ("探すフォルダ数" & l & " 増減します")} --進行状況のカウント
(* ファイル取得 *) set obj to item 1 of searchFolder set filelistObj to every file of folder obj repeat with oneItem in filelistObj if addressPath then set oneText to oneItem as text else set oneText to (name of file (oneItem as text)) as text end if if oneText ends with ".app" then set applicationList to applicationList & oneText & (ASCII character 10) --return end repeat (* 下層フォルダが見つかった場合に上乗せで追加 *) set folderObj to every folder of folder obj if (count of folderObj) > 0 then repeat with oneFolder in folderObj set searchFolder to searchFolder & {oneFolder as text} end repeat end if set l to count of searchFolder if l > 1 then set searchFolder to items 2 thru -1 of searchFolder else exit repeat end if end repeat end tell
(* 終了処理 *) set applicationList to text from paragraph 2 to paragraph -1 of applicationList if l = 1 then log "完了" else log "検索作業は未完了" log (count of searchFolder) end if log ("所要時間: " & ((current date) - aTime) & "秒") log (count of (every paragraph of applicationList)) set applicationList to do shell script ("echo '" & applicationList & "' | sort")
applicationList
|
コメント 0