[savedSearch]検索条件ファイルを作成する
ダウンロード - makenewsavedseach.zip
テンプレートとなるPLISTを内包していますので
試す場合は↑をダウンロードしてお試しください
全部値を入れるの面倒だったのでテンプレートになるplistの値を入れ替える方式にした
#!/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.8"
use framework "Foundation"
use scripting additions
property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()
###ファイル名=表示名
set strFileName to "iCloud Driveを検索.savedSearch"
###検索対象のパス
set strFXScopePath to "~/Library/Mobile Documents" as text
#################################
tell application "Finder"
set aliasPathToMe to path to me as alias
set aliasContainerDir to container of aliasPathToMe as alias
set aliasTemplateFilePath to (file "template.savedSearch" of folder "template" of folder aliasContainerDir) as alias
end tell
###読み込みPLISTパス
set strTemplateFilePath to (POSIX path of aliasTemplateFilePath) as text
set ocidTemplateFilePath to refMe's NSString's stringWithString:(strTemplateFilePath)
set ocidTemplatePath to ocidTemplateFilePath's stringByStandardizingPath()
set ocidTemplatePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidTemplatePath) isDirectory:false)
###SavePlistPath
set ocidURLArray to appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask)
set ocidLibraryDirPathURL to ocidURLArray's firstObject()
set ocidSavedSearchesURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Saved Searches") isDirectory:true
set ocidSavedFileURL to ocidSavedSearchesURL's URLByAppendingPathComponent:(strFileName) isDirectory:false
##FXScopeArrayOfPaths
set ocidFXScopePathStr to refMe's NSString's stringWithString:(strFXScopePath)
set ocidFXScopePath to ocidFXScopePathStr's stringByStandardizingPath()
set strFXScopePath to ocidFXScopePath as text
##SearchScopes
set strSearchScopesPath to ("/System/Volumes/Data" & strFXScopePath & "") as text
set ocidSearchScopesPathStr to refMe's NSString's stringWithString:(strSearchScopesPath)
set ocidSearchScopesPath to ocidSearchScopesPathStr's stringByStandardizingPath()
set strSearchScopesPath to ocidSearchScopesPath as text
#################################
####PLIST編集
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidTemplatePathURL)
set ocidRawQuery to ocidPlistDict's objectForKey:"RawQueryDict"
set ocidSearchScopes to ocidRawQuery's objectForKey:"SearchScopes"
set ocidNestArray to ocidSearchScopes's firstObject()
ocidNestArray's replaceObjectAtIndex:0 withObject:(strSearchScopesPath)
####
set ocidSearchCriteria to ocidPlistDict's objectForKey:"SearchCriteria"
set ocidFXScope to ocidSearchCriteria's objectForKey:"FXScopeArrayOfPaths"
ocidFXScope's replaceObjectAtIndex:0 withObject:(strFXScopePath)
#################################
####保存
set boolDone to ocidPlistDict's writeToURL:(ocidSavedFileURL) atomically:true
log boolDone
set ocidSaveFilePath to ocidSavedFileURL's |path|()
###場所を示す
set ocidSharedWorkSpace to refMe's NSWorkspace's sharedWorkspace()
ocidSharedWorkSpace's selectFile:(ocidSaveFilePath) inFileViewerRootedAtPath:"/"
return
| 固定リンク
「XML savedSearch」カテゴリの記事
- savedSearch=スマートフォルダのアイコン(2024.05.23)
- [savedSearch]フォント用 保存済みの検索条件 (文字セット別)(2024.05.15)
- [savedSearch]保存済みの検索条件(2日以内に変更があるもの)(仮)(2024.05.15)
- [savedSearch]前面ウィンドウをrootで拡張子検索(途中)(2023.06.22)
- [savedSearch]検索条件ファイルを作成する(2023.06.21)