XML savedSearch

savedSearch=スマートフォルダのアイコン

OSに標準でインストールされているicnsファイルのパス一覧
https://quicktimer.cocolog-nifty.com/icefloe/2024/05/post-25168d.html
にあるように

202405230700291138x125

あくまでも参考にしてください

サンプルソース(参考)
行番号ソース
001#パスは
002/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/SmartFolderIcon.icns
AppleScriptで生成しました

|

[savedSearch]フォント用 保存済みの検索条件 (文字セット別)

202405150211381176x516

ダウンロード - Fonts_文字セット別.zip

|

[savedSearch]保存済みの検索条件(2日以内に変更があるもの)(仮)


あくまでも参考にしてください

【スクリプトエディタで開く】 |

サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#com.cocolog-nifty.quicktimer.icefloe
004# 留意事項 検索条件は上書きされます
005# 前面ウィンドウのパスで拡張子検索
006(*
007検索条件のカスタマイズはMDitem
008https://developer.apple.com/documentation/coreservices/file_metadata/mditem?language=objc
009*)
010----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
011use AppleScript version "2.8"
012use framework "Foundation"
013use framework "AppKit"
014use scripting additions
015
016property refMe : a reference to current application
017
018
019##########################################
020##検索パスと名称のレコード
021set recordKeyPath to {|Desktop|:"デスクトップ", |Pictures|:"ピクチャー", |Documents|:"書類", |Movies|:"ムービー", |Music|:"ミュージック", |Sites|:"サイト", |Downloads|:"ダウンロード"} as record
022set ocidKeyPathDict to refMe's NSMutableDictionary's alloc()'s initWithDictionary:(recordKeyPath)
023
024##########################################
025##キーの数だけ繰り返し
026set ocidAllKeys to ocidKeyPathDict's allKeys()
027repeat with itemKey in ocidAllKeys
028  set ocidValue to (ocidKeyPathDict's valueForKey:(itemKey))
029  set ocidSaveDirPathURL to doMakeSavedSearch({itemKey, ocidValue})
030end repeat
031
032##########################################
033##場所を示す savedSearchファイルをFinderで開く
034set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
035set boolDone to appSharedWorkspace's openURL:(ocidSaveDirPathURL)
036
037
038
039##########################################
040##ファイル生成サブ
041to doMakeSavedSearch({argPath, argSaveName})
042  set strPath to argPath as text
043  set strSaveName to argSaveName as text
044  ##########################################
045    set appFileManager to refMe's NSFileManager's defaultManager()
046  set ocidUserName to refMe's NSUserName()
047  set strUserName to ocidUserName as text
048  ####【1】検索ルートパス
049  set ocidUserName to refMe's NSUserName()
050  set strUserName to ocidUserName as text
051  ##FXScopeパス
052  set strFXScopePath to ("/System/Volumes/Data/Users/" & strUserName & "/" & strPath) as text
053  set ocidFXScopePathStr to refMe's NSString's stringWithString:(strFXScopePath)
054  set ocidFXScopePath to ocidFXScopePathStr's stringByStandardizingPath()
055  set ocidFXScopePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFXScopePath) isDirectory:(false)
056  set ocidFXScopeDirFileName to ocidFXScopePathURL's lastPathComponent()
057  set ocidFXScopePath to ocidFXScopePathURL's |path|()
058  ##DirPath
059  set ocidHomeDirURL to appFileManager's homeDirectoryForCurrentUser()
060  set ocidCurrentFolderPathURL to ocidHomeDirURL's URLByAppendingPathComponent:(strPath) isDirectory:(true)
061  set ocidCurrentFolderPath to ocidCurrentFolderPathURL's |path|()
062  ###  FXScopeのスコープ番号を取得
063  set listResponse to (ocidFXScopePathURL's getResourceValue:(reference) forKey:(refMe's NSURLFileContentIdentifierKey) |error| :(reference))
064  if (item 1 of listResponse) is (true) then
065    log "正常処理"
066    set ocidScopeNo to (item 2 of listResponse)
067  else if (item 3 of listResponse) ≠ (missing value) then
068    log (item 3 of listResponse)'s code() as text
069    log (item 3 of listResponse)'s localizedDescription() as text
070    return "FXScopeでエラーしました"
071  end if
072  
073  ###PLIST(savedSearch)保存先 ディレクトリ
074  set appFileManager to refMe's NSFileManager's defaultManager()
075  set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
076  set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
077  set ocidSaveDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Saved Searches/直近検索") isDirectory:true
078  ###フォルダを作る
079  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
080  ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
081  set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
082  ###localizedを作る
083  set ocidNulText to refMe's NSString's stringWithString:("")
084  set ocidLocalizedPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(".localized")
085  set listDone to ocidNulText's writeToURL:(ocidLocalizedPathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference)
086  if (item 1 of listDone) is true then
087    log "保存先フォルダ作成正常処理"
088  else if (item 2 of listDone) ≠ (missing value) then
089    log (item 2 of listDone)'s code() as text
090    log (item 2 of listDone)'s localizedDescription() as text
091    return "保存先フォルダ作成 エラーしました"
092  end if
093  ##
094  set strFileName to (strSaveName & "-2日以内.savedSearch") as text
095  set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:false
096  
097  ##########################################
098  ####【5】PLIST=DICT= savedSearch新規作成
099  set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
100  
101  ########【A】ROOT
102  #ROOTに追加
103  ocidPlistDict's setValue:(1 as integer) forKey:"CompatibleVersion"
104  #ROOTに追加
105  set strSetValue to "InRange(kMDItemContentModificationDate,$time.today(-2d),$time.today(+1d))" as text
106  ocidPlistDict's setValue:(strSetValue) forKey:"RawQuery"
107  ########【B】SuggestedAttributes
108  set ocidSetArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
109  #ROOTに追加
110  ocidPlistDict's setObject:(ocidSetArray) forKey:"SuggestedAttributes"
111  ########【C】ViewSettings
112  set ocidViewSettingsDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
113  ###【C-1】WindowState
114  set ocidSetDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
115  ocidSetDict's setValue:(true as boolean) forKey:("ContainerShowSidebar")
116  ocidSetDict's setValue:(true as boolean) forKey:("ShowSidebar")
117  ocidSetDict's setValue:(true as boolean) forKey:("ShowStatusBar")
118  ocidSetDict's setValue:(true as boolean) forKey:("ShowTabView")
119  ocidSetDict's setValue:(true as boolean) forKey:("ShowToolbar")
120  ocidSetDict's setValue:({{0, 50}, {720, 520}}) forKey:("WindowBounds")
121  ocidViewSettingsDict's setObject:(ocidSetDict) forKey:("WindowState")
122  ###【C-2】ListViewSettings
123  set ocidSetDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
124  ocidSetDict's setValue:(true as boolean) forKey:("calculateAllSizes")
125  ocidSetDict's setValue:(true as boolean) forKey:("showIconPreview")
126  ocidSetDict's setValue:(false as boolean) forKey:("useRelativeDates")
127  ocidSetDict's setValue:(13 as integer) forKey:("axTextSize")
128  ocidSetDict's setValue:(16 as integer) forKey:("iconSize")
129  ocidSetDict's setValue:(13 as integer) forKey:("textSize")
130  ocidSetDict's setValue:(13 as integer) forKey:("viewOptionsVersion")
131  ocidSetDict's setValue:("dateLastOpened" as string) forKey:("sortColumn")
132  ocidViewSettingsDict's setObject:(ocidSetDict) forKey:("ListViewSettings")
133  ###【C-3】ExtendedListViewSettingsV2
134  set ocidSetDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
135  ocidSetDict's setValue:(true as boolean) forKey:("calculateAllSizes")
136  ocidSetDict's setValue:(true as boolean) forKey:("showIconPreview")
137  ocidSetDict's setValue:(false as boolean) forKey:("useRelativeDates")
138  ocidSetDict's setValue:(13 as integer) forKey:("axTextSize")
139  ocidSetDict's setValue:(16 as integer) forKey:("iconSize")
140  ocidSetDict's setValue:(13 as integer) forKey:("textSize")
141  ocidSetDict's setValue:(1 as integer) forKey:("viewOptionsVersion")
142  ocidSetDict's setValue:("dateLastOpened" as string) forKey:("sortColumn")
143  ocidViewSettingsDict's setObject:(ocidSetDict) forKey:("ExtendedListViewSettingsV2")
144  ###ViewSettingsmをROOTに追加
145  ocidPlistDict's setObject:(ocidViewSettingsDict) forKey:"ViewSettings"
146  ########【D】SearchCriteria
147  #ROOTにセットするレコード
148  set ocidSearchCriteriaDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
149  ##【D-1】スコープ番号
150  ocidSearchCriteriaDict's setValue:(ocidScopeNo) forKey:("FXScope")
151  (*  FXScopeArrayOfPaths
152#全件
153kMDQueryScopeHome
154kMDQueryScopeComputer
155kMDQueryScopeNetwork
156#牽引あり
157kMDQueryScopeAllIndexed
158kMDQueryScopeComputerIndexed
159kMDQueryScopeNetworkIndexed
160#パス指定スコープ指定混在の場合
161set listSetValue to {ocidFXScopePath, "kMDQueryScopeAllIndexed"} as list
162set ocidSetArray to refMe's NSMutableArray's alloc()'s initWithArray:(listSetValue)
163*)
164  ##【D-2】FXScopeArrayOfPaths
165  set ocidSetArray to refMe's NSMutableArray's arrayWithObject:(ocidCurrentFolderPath)
166  ocidSearchCriteriaDict's setObject:(ocidSetArray) forKey:("FXScopeArrayOfPaths")
167  ##【D-3】CurrentFolderPath
168  set ocidSetArray to refMe's NSMutableArray's arrayWithObject:(ocidCurrentFolderPath)
169  ocidSearchCriteriaDict's setObject:(ocidSetArray) forKey:"CurrentFolderPath"
170  ##【D-4】FXCriteriaSlices
171  set ocidSetDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
172  #
173  set listSetValue to {"kMDItemContentModificationDate", 800, 801, 900, 901} as list
174  set ocidSetArray to refMe's NSMutableArray's alloc()'s initWithArray:(listSetValue)
175  ocidSetDict's setObject:(ocidSetArray) forKey:("criteria")
176  #
177  set listSetValue to {"コンテンツの変更日", "is", "within last", "2", "days"} as list
178  set ocidSetArray to refMe's NSMutableArray's alloc()'s initWithArray:(listSetValue)
179  ocidSetDict's setObject:(ocidSetArray) forKey:("displayValues")
180  #
181  ocidSetDict's setValue:(0 as integer) forKey:("rowType")
182  #
183  set ocidSetChildArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
184  ocidSetDict's setObject:(ocidSetChildArray) forKey:("subrows")
185  #
186  set ocidSetArray to refMe's NSMutableArray's arrayWithObject:(ocidSetDict)
187  ocidSearchCriteriaDict's setObject:(ocidSetArray) forKey:"FXCriteriaSlices"
188  #ROOTに追加
189  ocidPlistDict's setObject:(ocidSearchCriteriaDict) forKey:"SearchCriteria"
190  
191  ########【E】RawQueryDict
192  set ocidRawQueryDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
193  ##【E-1】 FinderFilesOnly
194  ocidRawQueryDict's setValue:(true as boolean) forKey:("FinderFilesOnly")
195  ##【E-2】UserFilesOnly
196  ocidRawQueryDict's setValue:(true as boolean) forKey:("UserFilesOnly")
197  ##【E-3】kMDItemGroupId
198  (*    kMDItemGroupId
1997=ムービー
2008=実行可能=APP
2019=フォルダ
20210=音楽
20311=PDF
20412=プレゼンテーション
20513=画像
206set strSetValue to "(_kMDItemGroupId = 7)" as text
207
208kMDItemContentTypeTree
209kMDItemContentTypeTree= UTI
210kMDItemContentTypeTree = public.text
211
212set strSetValue to "(_kMDItemContentTypeTree = public.text)" as text
213
214
215/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata.tbd
216kMDItemAdamID
217kMDItemContentChangeDate
218kMDItemCreationDate
219kMDItemCreatorCode
220kMDItemExportImporterAvaliable
221kMDItemFSContentType
222kMDItemFSContentTypeTree
223kMDItemFSDisplayName
224kMDItemFileName
225kMDItemFinderFlags
226kMDItemFinderLabel
227kMDItemHasCustomIcon
228kMDItemHasExtensionHidden
229kMDItemImporterResult
230kMDItemInvisibleFileType
231kMDItemIsEvictedFile
232kMDItemIsExtensionHidden
233kMDItemIsStationery
234kMDItemLocked
235kMDItemNodeCount
236kMDItemOwnerGroupID
237kMDItemOwnerUserID
238kMDItemPrescanCandidate
239kMDItemServerVersion
240kMDItemSortIdentityAttr
241kMDItemStaticInterestScore
242kMDItemSupportFileType
243kMDItemTextContentIndexExists
244kMDItemTypeCode
245kMDItemUserTags
246kMDItemAcquisitionMake
247kMDItemAcquisitionModel
248kMDItemAlbum
249kMDItemAlternateNames
250kMDItemAltitude
251kMDItemAperture
252kMDItemAppleLoopDescriptors
253kMDItemAppleLoopsKeyFilterType
254kMDItemAppleLoopsLoopMode
255kMDItemAppleLoopsRootKey
256kMDItemApplicationCategories
257kMDItemAttributeChangeDate
258kMDItemAudiences
259kMDItemAudioBitRate
260kMDItemAudioChannelCount
261kMDItemAudioEncodingApplication
262kMDItemAudioSampleRate
263kMDItemAudioTrackNumber
264kMDItemAuthorAddresses
265kMDItemAuthorEmailAddresses
266kMDItemAuthors
267kMDItemBitsPerSample
268kMDItemCFBundleIdentifier
269kMDItemCameraOwner
270kMDItemCity
271kMDItemCodecs
272kMDItemColorSpace
273kMDItemComment
274kMDItemComposer
275kMDItemContactKeywords
276kMDItemContentCreationDate
277kMDItemContentModificationDate
278kMDItemContentType
279kMDItemContentTypeTree
280kMDItemContributors
281kMDItemCopyright
282kMDItemCountry
283kMDItemCoverage
284kMDItemCreator
285kMDItemDateAdded
286kMDItemDeliveryType
287kMDItemDescription
288kMDItemDestinationRecipients
289kMDItemDidChangeNotification
290kMDItemDirector
291kMDItemDisplayName
292kMDItemDisplayNameInitials
293kMDItemDocumentContainer
294kMDItemDownloadedDate
295kMDItemDueDate
296kMDItemDurationSeconds
297kMDItemEXIFGPSVersion
298kMDItemEXIFVersion
299kMDItemEditors
300kMDItemEmailAddresses
301kMDItemEncodingApplications
302kMDItemExecutableArchitectures
303kMDItemExecutablePlatform
304kMDItemExposureMode
305kMDItemExposureProgram
306kMDItemExposureTimeSeconds
307kMDItemExposureTimeString
308kMDItemFNumber
309kMDItemFSContentChangeDate
310kMDItemFSCreationDate
311kMDItemFSCreatorCode
312kMDItemFSExists
313kMDItemFSFinderFlags
314kMDItemFSHasCustomIcon
315kMDItemFSInvisible
316kMDItemFSIsExtensionHidden
317kMDItemFSIsReadable
318kMDItemFSIsStationery
319kMDItemFSIsWriteable
320kMDItemFSLabel
321kMDItemFSName
322kMDItemFSNodeCount
323kMDItemFSOwnerGroupID
324kMDItemFSOwnerUserID
325kMDItemFSSize
326kMDItemFSTypeCode
327kMDItemFinderComment
328kMDItemFinderOpenDate
329kMDItemFlashOnOff
330kMDItemFocalLength
331kMDItemFocalLength35mm
332kMDItemFonts
333kMDItemGPSAreaInformation
334kMDItemGPSDOP
335kMDItemGPSDateStamp
336kMDItemGPSDestBearing
337kMDItemGPSDestDistance
338kMDItemGPSDestLatitude
339kMDItemGPSDestLongitude
340kMDItemGPSDifferental
341kMDItemGPSMapDatum
342kMDItemGPSMeasureMode
343kMDItemGPSProcessingMethod
344kMDItemGPSStatus
345kMDItemGPSTrack
346kMDItemGenre
347kMDItemHTMLContent
348kMDItemHasAlphaChannel
349kMDItemHeadline
350kMDItemISOSpeed
351kMDItemIdentifier
352kMDItemImageDirection
353kMDItemInformation
354kMDItemInstantMessageAddresses
355kMDItemInstructions
356kMDItemIsApplicationManaged
357kMDItemIsGeneralMIDISequence
358kMDItemIsLikelyJunk
359kMDItemIsQuarantined
360kMDItemKeySignature
361kMDItemKeywords
362kMDItemKind
363kMDItemLabelID
364kMDItemLabelIcon
365kMDItemLabelKind
366kMDItemLabelUUID
367kMDItemLanguages
368kMDItemLastUsedDate
369kMDItemLatitude
370kMDItemLayerNames
371kMDItemLensModel
372kMDItemLogicalSize
373kMDItemLongitude
374kMDItemLyricist
375kMDItemMaxAperture
376kMDItemMediaTypes
377kMDItemMeteringMode
378kMDItemMusicalGenre
379kMDItemMusicalInstrumentCategory
380kMDItemMusicalInstrumentName
381kMDItemNamedLocation
382kMDItemNumberOfPages
383kMDItemOrganizations
384kMDItemOrientation
385kMDItemOriginApplicationIdentifier
386kMDItemOriginMessageID
387kMDItemOriginSenderDisplayName
388kMDItemOriginSenderHandle
389kMDItemOriginSubject
390kMDItemOriginalFormat
391kMDItemOriginalSource
392kMDItemPageHeight
393kMDItemPageWidth
394kMDItemParticipants
395kMDItemPath
396kMDItemPerformers
397kMDItemPhoneNumbers
398kMDItemPhysicalSize
399kMDItemPixelCount
400kMDItemPixelHeight
401kMDItemPixelWidth
402kMDItemProducer
403kMDItemProfileName
404kMDItemProjects
405kMDItemPublishers
406kMDItemPurchaseDate
407kMDItemRecipientAddresses
408kMDItemRecipientEmailAddresses
409kMDItemRecipients
410kMDItemRecordingDate
411kMDItemRecordingYear
412kMDItemRedEyeOnOff
413kMDItemResolutionHeightDPI
414kMDItemResolutionWidthDPI
415kMDItemRights
416kMDItemSecurityMethod
417kMDItemSpeed
418kMDItemStarRating
419kMDItemStateOrProvince
420kMDItemStreamable
421kMDItemSubject
422kMDItemSupportFileType
423kMDItemTempo
424kMDItemTextContent
425kMDItemTheme
426kMDItemTimeSignature
427kMDItemTimestamp
428kMDItemTitle
429kMDItemTotalBitRate
430kMDItemURL
431kMDItemUsedDates
432kMDItemUserTags
433kMDItemVersion
434kMDItemVideoBitRate
435kMDItemWhereFroms
436kMDItemWhiteBalance
437#ファイル またはディレクトリ名
438set strSetValue to "(_kMDItemFileName = \"*." & strExName & "\"c)" as text
439*)
440  
441  #3日以内
442  set strSetValue to "InRange(kMDItemContentModificationDate,$time.today(-2d),$time.today(+1d))" as text
443  ocidRawQueryDict's setValue:(strSetValue) forKey:"RawQuery"
444  ##【E-4】SearchScopes
445  (* SearchScopes
446https://developer.apple.com/documentation/coreservices/file_metadata/mdquery/query_search_scope_keys?language=objc
447#全件
448kMDQueryScopeHome
449kMDQueryScopeComputer
450kMDQueryScopeNetwork
451#牽引あり
452kMDQueryScopeAllIndexed
453kMDQueryScopeComputerIndexed
454kMDQueryScopeNetworkIndexed
455#牽引されている内容から検索
456set listSetValue to {"kMDQueryScopeAllIndexed"} as list
457#全件対象
458set listSetValue to {"kMDQueryScopeHome", "kMDQueryScopeComputer", "kMDQueryScopeNetwork"} as list
459#牽引されている内容から検索+ホームディレクトリは全件
460set listSetValue to {"kMDQueryScopeHome", "kMDQueryScopeComputerIndexed", "kMDQueryScopeNetworkIndexed"} as list
461#SearchScopes指定の場合
462set ocidChildArray to refMe's NSMutableArray's alloc()'s initWithArray:(listSetValue)
463*)
464  #パス指定の場合
465  set ocidChildArray to refMe's NSMutableArray's arrayWithObject:(ocidFXScopePath)
466  #親Arrayにセットして
467  set ocidSetArray to refMe's NSMutableArray's alloc()'s initWithArray:(ocidChildArray)
468  #SearchScopesにセットする
469  ocidRawQueryDict's setObject:(ocidSetArray) forKey:("SearchScopes")
470  #ROOTに追加
471  ocidPlistDict's setObject:(ocidRawQueryDict) forKey:("RawQueryDict")
472  
473  
474  
475  ##########################################
476  ####【6】PLISTに変換 (optionは 0-2  Immutable /MutableContainers /MutableContainersAndLeaves)
477  set ocidFromat to refMe's NSPropertyListXMLFormat_v1_0
478  set listResponse to refMe's NSPropertyListSerialization's dataWithPropertyList:(ocidPlistDict) format:(ocidFromat) options:0  |error| :(reference)
479  if (item 2 of listResponse) = (missing value) then
480    log "正常処理"
481    set ocidPlistEditData to (item 1 of listResponse)
482  else if (item 2 of listResponse) ≠ (missing value) then
483    log (item 2 of listResponse)'s code() as text
484    log (item 2 of listResponse)'s localizedDescription() as text
485    return "シリアライゼーションでエラーしました"
486  end if
487  
488  ##########################################
489  ####【7】保存
490  set listDone to ocidPlistEditData's writeToURL:(ocidSaveFilePathURL) options:(refMe's NSDataWritingAtomic) |error| :(reference)
491  if (item 2 of listDone) = (missing value) then
492    log "正常処理"
493    set ocidPlistEditData to (item 1 of listDone)
494  else if (item 2 of listDone) ≠ (missing value) then
495    log (item 2 of listDone)'s code() as text
496    log (item 2 of listDone)'s localizedDescription() as text
497    return "保存でエラーしました"
498  end if
499  
500  return ocidSaveDirPathURL
501end doMakeSavedSearch
AppleScriptで生成しました

|

[savedSearch]前面ウィンドウをrootで拡張子検索(途中)

ダウンロード -拡張子検索.zip


【スクリプトエディタで開く】|

#!/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

#################################
##ファイルパスの収集
tell application "Finder"
  set aliasPathToMe to path to me as alias
  set aliasContainerDir to container of aliasPathToMe as alias
  set aliasSavedSearchDir to (folder "savedSearch" of folder aliasContainerDir) as alias
  set listFilePath to (get every item of aliasSavedSearchDir) as list
  log listFilePath
end tell
#################################
##ファイルパス→エイリアスパス
set listAliasPath to {} as list
repeat with itemFilePath in listFilePath
  set aliasFilePath to itemFilePath as alias
  set end of listAliasPath to aliasFilePath
end repeat
log listAliasPath
#################################
##エイリアスパス→ファイル名のリスト
set listFileName to {} as list
repeat with itemAliasPath in listAliasPath
  tell application "Finder"
    set strFileName to name of itemAliasPath as text
  end tell
  set end of listFileName to strFileName
end repeat
log listFileName
#################################
##ダイアログ
try
  ###ダイアログを前面に出す
  tell current application
    set strName to name as text
  end tell
  ####スクリプトメニューから実行したら
  if strName is "osascript" then
    tell application "Finder"
      activate
    end tell
  else
    tell current application
      activate
    end tell
  end if
  set listResponse to (choose from list listFileName with title "選んでください" with prompt "選んでください" default items (item 1 of listFileName) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
  log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしました"
end if
set strFileName to (item 1 of listResponse) as text

tell application "Finder"
  set aliasFilePath to (file strFileName of folder aliasSavedSearchDir) as alias
end tell
set strSearchFilePath to (POSIX path of aliasFilePath) as text

#################################
##起動時に削除される項目
tell application "Finder"
  set aliasTemporaryPath to path to temporary items from local domain as alias with folder creation
end tell
set strTemporaryPath to (POSIX path of aliasTemporaryPath) as text

###読み込みPLISTパス
set ocidTemplateFilePath to refMe's NSString's stringWithString:(strSearchFilePath)
set ocidTemplatePath to ocidTemplateFilePath's stringByStandardizingPath()
set ocidTemplatePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidTemplatePath) isDirectory:false)

###SavePlistPath
set ocidTemporaryPathStr to refMe's NSString's stringWithString:(strTemporaryPath)
set ocidTemporaryPath to ocidTemporaryPathStr's stringByStandardizingPath()
set ocidTemporaryPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidTemporaryPath) isDirectory:true)
set ocidSavedFileURL to ocidTemporaryPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:false
#################################
##前面のFinderウィンドウのパスを取得
tell application "Finder"
  tell front Finder window
    set fileTargetPath to target
  end tell
  set aliasTargetPath to fileTargetPath as alias
end tell
set strFXScopePath to (POSIX path of aliasTargetPath) as text
#################################
##前面FinderWindowのBoundsを取得
tell application "Finder"
  tell front Finder window
    set listbounds to bounds
  end tell
end tell
#################################
##bound to rect
set numX to item 1 of listbounds as number
set numY to item 2 of listbounds as number
set numWidth to item 3 of listbounds as number
set numHeight to item 4 of listbounds as number
####
##位置を右下へ10
set numX to numX + 10 as number
set numY to numY + 10 as number
###注意 テキストです
set strWindowBounds to "{{" & numX & "," & numY & "},{" & numWidth & "," & numHeight & "}}" as text

##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 ocidViewSettings to ocidPlistDict's objectForKey:"ViewSettings"
set ocidWindowState to ocidViewSettings's objectForKey:"WindowState"
ocidWindowState's setValue:(strWindowBounds) forKey:("WindowBounds")

#################################
####保存
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()

set strUTI to "com.apple.finder"
set ocidAppBundle to refMe's NSBundle's bundleWithIdentifier:(strUTI)
###
if ocidAppBundle is not (missing value) then
  set ocidAppBundlePathURL to ocidAppBundle's bundleURL()
  set strFilePath to ocidAppBundlePathURL's |path|() as text
else
  set ocidAppBundlePathURL to appNSWorkspace's URLForApplicationWithBundleIdentifier:(strUTI)
  set ocidAppBundle to refMe's NSBundle's bundleWithURL:(ocidAppBundlePathURL)
  set strFilePath to ocidAppBundlePathURL's |path|() as text
end if
set ocidFalse to (refMe's NSNumber's numberWithBool:false)'s boolValue
set ocidTrue to (refMe's NSNumber's numberWithBool:true)'s boolValue
set ocidConfig to refMe's NSWorkspaceOpenConfiguration's configuration()
ocidConfig's setHides:ocidFalse
ocidConfig's setRequiresUniversalLinks:ocidFalse
ocidConfig's setActivates:ocidTrue

ocidSharedWorkSpace's openURLs:{ocidSavedFileURL} withApplicationAtURL:(ocidAppBundlePathURL) configuration:(ocidConfig) completionHandler:(missing value)

return


|

[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


|

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code VMware Fusion Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom