[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 |
008 | https://developer.apple.com/documentation/coreservices/file_metadata/mditem?language=objc |
009 | *) |
010 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
011 | use AppleScript version "2.8" |
012 | use framework "Foundation" |
013 | use framework "AppKit" |
014 | use scripting additions |
015 | |
016 | property refMe : a reference to current application |
017 | |
018 | |
019 | ########################################## |
020 | ##検索パスと名称のレコード |
021 | set recordKeyPath to {|Desktop|:"デスクトップ", |Pictures|:"ピクチャー", |Documents|:"書類", |Movies|:"ムービー", |Music|:"ミュージック", |Sites|:"サイト", |Downloads|:"ダウンロード"} as record |
022 | set ocidKeyPathDict to refMe's NSMutableDictionary's alloc()'s initWithDictionary:(recordKeyPath) |
023 | |
024 | ########################################## |
025 | ##キーの数だけ繰り返し |
026 | set ocidAllKeys to ocidKeyPathDict's allKeys() |
027 | repeat with itemKey in ocidAllKeys |
028 | set ocidValue to (ocidKeyPathDict's valueForKey:(itemKey)) |
029 | set ocidSaveDirPathURL to doMakeSavedSearch({itemKey, ocidValue}) |
030 | end repeat |
031 | |
032 | ########################################## |
033 | ##場所を示す savedSearchファイルをFinderで開く |
034 | set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace() |
035 | set boolDone to appSharedWorkspace's openURL:(ocidSaveDirPathURL) |
036 | |
037 | |
038 | |
039 | ########################################## |
040 | ##ファイル生成サブ |
041 | to 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 | #全件 |
153 | kMDQueryScopeHome |
154 | kMDQueryScopeComputer |
155 | kMDQueryScopeNetwork |
156 | #牽引あり |
157 | kMDQueryScopeAllIndexed |
158 | kMDQueryScopeComputerIndexed |
159 | kMDQueryScopeNetworkIndexed |
160 | #パス指定スコープ指定混在の場合 |
161 | set listSetValue to {ocidFXScopePath, "kMDQueryScopeAllIndexed"} as list |
162 | set 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 |
199 | 7=ムービー |
200 | 8=実行可能=APP |
201 | 9=フォルダ |
202 | 10=音楽 |
203 | 11=PDF |
204 | 12=プレゼンテーション |
205 | 13=画像 |
206 | set strSetValue to "(_kMDItemGroupId = 7)" as text |
207 | |
208 | kMDItemContentTypeTree |
209 | kMDItemContentTypeTree= UTI |
210 | kMDItemContentTypeTree = public.text |
211 | |
212 | set strSetValue to "(_kMDItemContentTypeTree = public.text)" as text |
213 | |
214 | |
215 | /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata.tbd |
216 | kMDItemAdamID |
217 | kMDItemContentChangeDate |
218 | kMDItemCreationDate |
219 | kMDItemCreatorCode |
220 | kMDItemExportImporterAvaliable |
221 | kMDItemFSContentType |
222 | kMDItemFSContentTypeTree |
223 | kMDItemFSDisplayName |
224 | kMDItemFileName |
225 | kMDItemFinderFlags |
226 | kMDItemFinderLabel |
227 | kMDItemHasCustomIcon |
228 | kMDItemHasExtensionHidden |
229 | kMDItemImporterResult |
230 | kMDItemInvisibleFileType |
231 | kMDItemIsEvictedFile |
232 | kMDItemIsExtensionHidden |
233 | kMDItemIsStationery |
234 | kMDItemLocked |
235 | kMDItemNodeCount |
236 | kMDItemOwnerGroupID |
237 | kMDItemOwnerUserID |
238 | kMDItemPrescanCandidate |
239 | kMDItemServerVersion |
240 | kMDItemSortIdentityAttr |
241 | kMDItemStaticInterestScore |
242 | kMDItemSupportFileType |
243 | kMDItemTextContentIndexExists |
244 | kMDItemTypeCode |
245 | kMDItemUserTags |
246 | kMDItemAcquisitionMake |
247 | kMDItemAcquisitionModel |
248 | kMDItemAlbum |
249 | kMDItemAlternateNames |
250 | kMDItemAltitude |
251 | kMDItemAperture |
252 | kMDItemAppleLoopDescriptors |
253 | kMDItemAppleLoopsKeyFilterType |
254 | kMDItemAppleLoopsLoopMode |
255 | kMDItemAppleLoopsRootKey |
256 | kMDItemApplicationCategories |
257 | kMDItemAttributeChangeDate |
258 | kMDItemAudiences |
259 | kMDItemAudioBitRate |
260 | kMDItemAudioChannelCount |
261 | kMDItemAudioEncodingApplication |
262 | kMDItemAudioSampleRate |
263 | kMDItemAudioTrackNumber |
264 | kMDItemAuthorAddresses |
265 | kMDItemAuthorEmailAddresses |
266 | kMDItemAuthors |
267 | kMDItemBitsPerSample |
268 | kMDItemCFBundleIdentifier |
269 | kMDItemCameraOwner |
270 | kMDItemCity |
271 | kMDItemCodecs |
272 | kMDItemColorSpace |
273 | kMDItemComment |
274 | kMDItemComposer |
275 | kMDItemContactKeywords |
276 | kMDItemContentCreationDate |
277 | kMDItemContentModificationDate |
278 | kMDItemContentType |
279 | kMDItemContentTypeTree |
280 | kMDItemContributors |
281 | kMDItemCopyright |
282 | kMDItemCountry |
283 | kMDItemCoverage |
284 | kMDItemCreator |
285 | kMDItemDateAdded |
286 | kMDItemDeliveryType |
287 | kMDItemDescription |
288 | kMDItemDestinationRecipients |
289 | kMDItemDidChangeNotification |
290 | kMDItemDirector |
291 | kMDItemDisplayName |
292 | kMDItemDisplayNameInitials |
293 | kMDItemDocumentContainer |
294 | kMDItemDownloadedDate |
295 | kMDItemDueDate |
296 | kMDItemDurationSeconds |
297 | kMDItemEXIFGPSVersion |
298 | kMDItemEXIFVersion |
299 | kMDItemEditors |
300 | kMDItemEmailAddresses |
301 | kMDItemEncodingApplications |
302 | kMDItemExecutableArchitectures |
303 | kMDItemExecutablePlatform |
304 | kMDItemExposureMode |
305 | kMDItemExposureProgram |
306 | kMDItemExposureTimeSeconds |
307 | kMDItemExposureTimeString |
308 | kMDItemFNumber |
309 | kMDItemFSContentChangeDate |
310 | kMDItemFSCreationDate |
311 | kMDItemFSCreatorCode |
312 | kMDItemFSExists |
313 | kMDItemFSFinderFlags |
314 | kMDItemFSHasCustomIcon |
315 | kMDItemFSInvisible |
316 | kMDItemFSIsExtensionHidden |
317 | kMDItemFSIsReadable |
318 | kMDItemFSIsStationery |
319 | kMDItemFSIsWriteable |
320 | kMDItemFSLabel |
321 | kMDItemFSName |
322 | kMDItemFSNodeCount |
323 | kMDItemFSOwnerGroupID |
324 | kMDItemFSOwnerUserID |
325 | kMDItemFSSize |
326 | kMDItemFSTypeCode |
327 | kMDItemFinderComment |
328 | kMDItemFinderOpenDate |
329 | kMDItemFlashOnOff |
330 | kMDItemFocalLength |
331 | kMDItemFocalLength35mm |
332 | kMDItemFonts |
333 | kMDItemGPSAreaInformation |
334 | kMDItemGPSDOP |
335 | kMDItemGPSDateStamp |
336 | kMDItemGPSDestBearing |
337 | kMDItemGPSDestDistance |
338 | kMDItemGPSDestLatitude |
339 | kMDItemGPSDestLongitude |
340 | kMDItemGPSDifferental |
341 | kMDItemGPSMapDatum |
342 | kMDItemGPSMeasureMode |
343 | kMDItemGPSProcessingMethod |
344 | kMDItemGPSStatus |
345 | kMDItemGPSTrack |
346 | kMDItemGenre |
347 | kMDItemHTMLContent |
348 | kMDItemHasAlphaChannel |
349 | kMDItemHeadline |
350 | kMDItemISOSpeed |
351 | kMDItemIdentifier |
352 | kMDItemImageDirection |
353 | kMDItemInformation |
354 | kMDItemInstantMessageAddresses |
355 | kMDItemInstructions |
356 | kMDItemIsApplicationManaged |
357 | kMDItemIsGeneralMIDISequence |
358 | kMDItemIsLikelyJunk |
359 | kMDItemIsQuarantined |
360 | kMDItemKeySignature |
361 | kMDItemKeywords |
362 | kMDItemKind |
363 | kMDItemLabelID |
364 | kMDItemLabelIcon |
365 | kMDItemLabelKind |
366 | kMDItemLabelUUID |
367 | kMDItemLanguages |
368 | kMDItemLastUsedDate |
369 | kMDItemLatitude |
370 | kMDItemLayerNames |
371 | kMDItemLensModel |
372 | kMDItemLogicalSize |
373 | kMDItemLongitude |
374 | kMDItemLyricist |
375 | kMDItemMaxAperture |
376 | kMDItemMediaTypes |
377 | kMDItemMeteringMode |
378 | kMDItemMusicalGenre |
379 | kMDItemMusicalInstrumentCategory |
380 | kMDItemMusicalInstrumentName |
381 | kMDItemNamedLocation |
382 | kMDItemNumberOfPages |
383 | kMDItemOrganizations |
384 | kMDItemOrientation |
385 | kMDItemOriginApplicationIdentifier |
386 | kMDItemOriginMessageID |
387 | kMDItemOriginSenderDisplayName |
388 | kMDItemOriginSenderHandle |
389 | kMDItemOriginSubject |
390 | kMDItemOriginalFormat |
391 | kMDItemOriginalSource |
392 | kMDItemPageHeight |
393 | kMDItemPageWidth |
394 | kMDItemParticipants |
395 | kMDItemPath |
396 | kMDItemPerformers |
397 | kMDItemPhoneNumbers |
398 | kMDItemPhysicalSize |
399 | kMDItemPixelCount |
400 | kMDItemPixelHeight |
401 | kMDItemPixelWidth |
402 | kMDItemProducer |
403 | kMDItemProfileName |
404 | kMDItemProjects |
405 | kMDItemPublishers |
406 | kMDItemPurchaseDate |
407 | kMDItemRecipientAddresses |
408 | kMDItemRecipientEmailAddresses |
409 | kMDItemRecipients |
410 | kMDItemRecordingDate |
411 | kMDItemRecordingYear |
412 | kMDItemRedEyeOnOff |
413 | kMDItemResolutionHeightDPI |
414 | kMDItemResolutionWidthDPI |
415 | kMDItemRights |
416 | kMDItemSecurityMethod |
417 | kMDItemSpeed |
418 | kMDItemStarRating |
419 | kMDItemStateOrProvince |
420 | kMDItemStreamable |
421 | kMDItemSubject |
422 | kMDItemSupportFileType |
423 | kMDItemTempo |
424 | kMDItemTextContent |
425 | kMDItemTheme |
426 | kMDItemTimeSignature |
427 | kMDItemTimestamp |
428 | kMDItemTitle |
429 | kMDItemTotalBitRate |
430 | kMDItemURL |
431 | kMDItemUsedDates |
432 | kMDItemUserTags |
433 | kMDItemVersion |
434 | kMDItemVideoBitRate |
435 | kMDItemWhereFroms |
436 | kMDItemWhiteBalance |
437 | #ファイル またはディレクトリ名 |
438 | set 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 |
446 | https://developer.apple.com/documentation/coreservices/file_metadata/mdquery/query_search_scope_keys?language=objc |
447 | #全件 |
448 | kMDQueryScopeHome |
449 | kMDQueryScopeComputer |
450 | kMDQueryScopeNetwork |
451 | #牽引あり |
452 | kMDQueryScopeAllIndexed |
453 | kMDQueryScopeComputerIndexed |
454 | kMDQueryScopeNetworkIndexed |
455 | #牽引されている内容から検索 |
456 | set listSetValue to {"kMDQueryScopeAllIndexed"} as list |
457 | #全件対象 |
458 | set listSetValue to {"kMDQueryScopeHome", "kMDQueryScopeComputer", "kMDQueryScopeNetwork"} as list |
459 | #牽引されている内容から検索+ホームディレクトリは全件 |
460 | set listSetValue to {"kMDQueryScopeHome", "kMDQueryScopeComputerIndexed", "kMDQueryScopeNetworkIndexed"} as list |
461 | #SearchScopes指定の場合 |
462 | set 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 |
501 | end doMakeSavedSearch |
AppleScriptで生成しました |
| 固定リンク
「XML savedSearch」カテゴリの記事
- savedSearch=スマートフォルダのアイコン(2024.05.23)
- [savedSearch]フォント用 保存済みの検索条件 (文字セット別)(2024.05.15)
- [savedSearch]保存済みの検索条件(2日以内に変更があるもの)(仮)(2024.05.15)
- [savedSearch]前面ウィンドウをrootで拡張子検索(途中)(2023.06.22)
- [savedSearch]検索条件ファイルを作成する(2023.06.21)