spotlight

How to get specific information about media files (Duration, Bitrate, FPS, etc.)

点点圈 提交于 2019-12-12 04:35:38
问题 I need to get the same kind of info that you can get on "Get Info" when using Finder; more specifically I need the same info that is present in the "More Info" section, like Duration, Bitrate, Dimension, Codecs, Audio channels, etc. To get the basic info like size, type, I have: // Getting the file's attributes NSError *error; NSFileManager *fm = [NSFileManager defaultManager]; NSDictionary *fileInfo = [fm attributesOfItemAtPath:fileName error:&error]; Is there any native Cocoa library to get

NSPredicate(s) for NSMetadataQuery to match kMDItemAccessedDates (array) containing a target date?

大城市里の小女人 提交于 2019-12-11 18:47:35
问题 UPDATE: I found an answer though there may still be a better way - see the answer added below. a spotlight importer imports metadata that is an array of dates in which an item was accessed. Looks like this: kMDItemAccessedDates = ( "2012-06-18 07:00:00 +0000", "2013-01-10 08:00:00 +0000", "2013-01-15 08:00:00 +0000" ) I'd like to query for any of these files that were accessed on a particular date the user enters but I'm not finding the right syntax to do this. Wondering if it's possible to

mdfind used for creating symlinks not working as expected

╄→尐↘猪︶ㄣ 提交于 2019-12-11 14:11:43
问题 I am trying to use the output from mdfind to create a bunch of symlinks. Output of mdfind is like this: /pathtofile1/ /pathtofile2/ /pathtofile3/ So, I used sed to add ln -s to the start of each line, and awk {print $0 "/directory where I want this/"} ; after my single-line script successfully outputs this: ln -s "/pathtofile1/" "/directory where I want this" ln -s "/pathtofile2/" "/directory where I want this" ln -s "/pathtofile3/" "/directory where I want this" Problem is, when I run this,

Get full text of search request from Spotlight?

一笑奈何 提交于 2019-12-11 11:51:27
问题 Since iOS9, it's possible to make Spotlight to show some items from own Application in search results. When user taps on result - App opens with some action handler. My question: is it possible somehow to get the full text of user's search request in application? Example: My application indexes item 'banana' using CoreSpotlight API. User searches: " banana pie ". Spotlight shows result from my App, actually, item " banana ". I would like to get string " banana pie ". I have already tried to

Getting all available folder metadata on OS X using swift

半腔热情 提交于 2019-12-11 09:56:11
问题 I'm writing a swift program, and I want to list all metadata of a given folder using swift. As I understand, I'll need NSMetadataItem . The reference doc of NSMetadataItem is not very clear to me though, so I'm unable to write a code sample here. How to list all metadata of a folder? 回答1: Initialize a new instance of NSMetadataItem with the folder's NSURL: let item = NSMetadataItem(URL: folderURL) Then safely unwrap the values: if let item = item, attributes = item.valuesForAttributes(item

Understanding crash report (Partial apply…) in Swift

我怕爱的太早我们不能终老 提交于 2019-12-10 13:22:31
问题 I'm new to Swift programming, Recently I have implemented spotlight search for my app with Swift. Everything is working well and good however I"m getting few crash reports nowadays and I have no clue what is "Partial apply" and why it is crashing. As I'm unable to simulate it locally I"m trying to solve it by using crash logs. Following is the crash report... Thread : Crashed: com.apple.root.default-qos 0 AppName 0x1076d4 partial apply for static spotLightSearchManager.(indexAllItem in

Query Mac OS X Spotlight from Java

邮差的信 提交于 2019-12-10 10:09:56
问题 Related to: Query Windows Search from Java But this time to use OSX's spotlight I would like to consume OSX spotlight service from Java. Is there an API available? . 回答1: There is no Java API for Spotlight that I am aware of (I don't think it was added to the now deprecated Cocoa-Java bridge development on the bridge was stopped). There is a procedural C API for Spotlight, however, that you could wrap with JNI. 回答2: I found some code that wraps the mdfind command line, works fine for me:

Strip metadata from files in Snow Leopard

人走茶凉 提交于 2019-12-10 00:58:29
问题 I found the command "mdls" which will show the metadata but I can't see how to delete it. I want to get rid of the comments "kMDItemFinderComment", "kMDItemWhereFroms" from my files. Is there a way to do this? 回答1: I think you're looking for the xattr command, available in Terminal: xattr -pr com.apple.metadata:kMDItemFinderComment / that will print all the finder comments for all files on your boot volume. To delete, use the -d switch: xattr -dr com.apple.metadata:kMDItemFinderComment / You

Mac Spotlight-API: how to search email's “to”, “from” or “subject” fields

寵の児 提交于 2019-12-08 13:39:27
问题 At the moment I have spotlight-api code which searches email's body. I'm using NSMetadataQuery and creating predicate for "kMDItemTextContent like[c] %@" . This works fine when requested "search-term" is in body of email. In Spotlight App (magnifier icon in top right) if I enter "to: john" I'll get list of emails in which "to" field contains word "john" (e.g. part of some email address john@something.com). I tried to achieve this with [NSCompoundPredicate orPredicateWithSubpredicates:] by

How can I choose a different iOS app name for Spotlight?

拥有回忆 提交于 2019-12-08 05:22:57
问题 The name of my app is French Translator + This app name is too long to be displayed under the app icon so I would like to shorten it to Translator +, however I would still like users to find it when searching Spotlight for "french". How can I register an app name for Spotlight searches that is different than app name appearing under the app icon. 回答1: You can always add your own keywords to the search index. Something like this: let attributeSet = CSSearchableItemAttributeSet(itemContentType: