[mdimport]Spotlightリセット(要管理者権限)
#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.6"
use framework "Foundation"
use scripting additions
property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()
do shell script "/usr/bin/sudo mdutil -i off -E" with administrator privileges
do shell script "/usr/bin/sudo mdutil -E /" with administrator privileges
do shell script "/usr/bin/sudo mdutil -i on /" with administrator privileges
##########################################
####### mdimporterへのパスリストを作成
##########################################
####ライブラリーのURL
set ocidLibraryURLArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSAllDomainsMask))
####戻り値格納用の可変リスト
set ocidURLArray to refMe's NSMutableArray's alloc()'s initWithCapacity:0
####ライブラリの数だけ繰り返し
repeat with itemLibraryURLArray in ocidLibraryURLArray
####Spotlightのディレクトリ
set ocidSpotlightDirURL to (itemLibraryURLArray's URLByAppendingPathComponent:"Spotlight" isDirectory:true)
####mdimporterへのパスを取得
set listContentsArray to (appFileManager's contentsOfDirectoryAtURL:ocidSpotlightDirURL includingPropertiesForKeys:{refMe's NSURLPathKey} options:(refMe's NSDirectoryEnumerationSkipsHiddenFiles) |error|:(reference))
set ocidContentsArray to item 1 of listContentsArray
if ocidContentsArray is not (missing value) then
####格納する
(ocidURLArray's addObjectsFromArray:ocidContentsArray)
end if
end repeat
##########################################
####### コマンド実行
##########################################
repeat with itemURLArray in ocidURLArray
##UNIXパスにして
set ocidFilePath to itemURLArray's |path|()
set strFilePath to ocidFilePath as text
###コマンド実行
set strCommandText to "/usr/bin/mdimport -r \"" & strFilePath & "\"" as text
do shell script strCommandText
end repeat
##########################################
####### オプション
##########################################
###アウトルック
set ocidAppBundle to refMe's NSBundle's bundleWithIdentifier:"com.microsoft.Outlook"
if ocidAppBundle is not (missing value) then
set ocidAppBundlePath to ocidAppBundle's bundlePath()
set ocidFilePath to ocidAppBundlePath's stringByStandardizingPath
set ocidFilePathArray to ocidFilePath's stringsByAppendingPaths:{"Contents/Library/Spotlight/Microsoft Outlook Spotlight Importer.mdimporter"}
set strFilePath to (ocidFilePathArray's objectAtIndex:0) as text
###コマンド実行
set strCommandText to "/usr/bin/mdimport -r \"" & strFilePath & "\"" as text
do shell script strCommandText
else
set appNSWorkspace to refMe's NSWorkspace's sharedWorkspace()
set ocidAppBundlePathURL to appNSWorkspace's URLForApplicationWithBundleIdentifier:"com.microsoft.Outlook"
set ocidSpotlightDirURL to (ocidAppBundlePathURL's URLByAppendingPathComponent:"Contents/Library/Spotlight/Microsoft Outlook Spotlight Importer.mdimporter" isDirectory:true)
set strFilePath to ocidSpotlightDirURL's |path|() as text
###コマンド実行
set strCommandText to "/usr/bin/mdimport -r \"" & strFilePath & "\"" as text
do shell script strCommandText
end if
###スクリプトデバッガー
set ocidAppBundle to refMe's NSBundle's bundleWithIdentifier:"com.latenightsw.ScriptDebugger8"
if ocidAppBundle is not (missing value) then
set ocidAppBundlePath to ocidAppBundle's bundlePath()
set ocidFilePath to ocidAppBundlePath's stringByStandardizingPath
set ocidFilePathArray to ocidFilePath's stringsByAppendingPaths:{"Contents/Library/Spotlight/SDImporter.mdimporter"}
set strFilePath to (ocidFilePathArray's objectAtIndex:0) as text
###コマンド実行
set strCommandText to "/usr/bin/mdimport -r \"" & strFilePath & "\"" as text
do shell script strCommandText
else
set appNSWorkspace to refMe's NSWorkspace's sharedWorkspace()
set ocidAppBundlePathURL to appNSWorkspace's URLForApplicationWithBundleIdentifier:"com.latenightsw.ScriptDebugger8"
set ocidSpotlightDirURL to (ocidAppBundlePathURL's URLByAppendingPathComponent:"Contents/Library/Spotlight/SDImporter.mdimporter" isDirectory:true)
set strFilePath to ocidSpotlightDirURL's |path|() as text
###コマンド実行
set strCommandText to "/usr/bin/mdimport -r \"" & strFilePath & "\"" as text
do shell script strCommandText
end if
##########################################
####### メールデータのインデックス
##########################################
do shell script "/usr/bin/mdimport -i $HOME/Library/Group\\ Containers/UBF8T346G9.Office/Outlook"
do shell script "/usr/bin/mdimport -i $HOME/Library/Mail"
###インポートポイントはあとはお好みで
return
| 固定リンク
「Spotlight」カテゴリの記事
- [Spotlight] Spotlightのインデックス牽引から除外した場所を調べる(2024.11.26)
- [defaults]設定変更の流れ(スポットライト メニューアイテムの表示・非表示)(2024.11.11)
- [Spotlight]カラープロファイルで検索(2024.09.30)
- [Spotlight]カラースペースで検索(2024.09.30)
- [Spotlight]検索キーの追加(mobileconfig)(2024.09.30)
「Admin Maintenance」カテゴリの記事
- [メンテナンス]ユーザーログファイルをゴミ箱に入れる(2024.11.30)
- [XProtect]アップデート macOS15.1.1(2024.11.20)
- [メンテナンス] Containers以下サンドボックスアプリのキャッシュを全部ゴミ箱に入れる(2024.11.09)
- [メンテナンス]Thumbs.dbやDS_Store等をゴミ箱に移動させる(2024.11.09)