1 ! Copyright (C) 2013 Charles Alston, John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax io.pathnames sequences strings ;
7 { $values { "query" string } { "results" sequence } }
9 "Finds files matching a given query."
11 { $snippet "mdfind [-live] [-count] [-onlyin directory] [-name fileName] query" }
13 "The mdfind command consults the central metadata store and returns a list of files that match the given metadata query. The query can be a string or a query expression."
15 { $subheading "Spotlight Keywords" }
16 "These can be included in the query expression to limit the type of documents returned:"
18 { "Applications" "kind:application, kind:applications, kind:app" }
19 { "Audio/Music" "kind:audio, kind:music" }
20 { "Bookmarks" "kind:bookmark, kind:bookmarks" }
21 { "Contacts" "kind:contact, kind:contacts" }
22 { "Email" "kind:email, kind:emails, kind:mail message, kind:mail messages" }
23 { "Folders" "kind:folder, kind:folders" }
24 { "Fonts" "kind:font, kind:fonts" }
25 { "iCal Events" "kind:event, kind:events" }
26 { "iCal To Dos" "kind:todo, kind:todos, kind:to do, kind:to dos" }
27 { "Images" "kind:image, kind:images" }
28 { "Movies" "kind:movie, kind:movies" }
29 { "PDF" "kind:pdf, kind:pdfs" }
30 { "Preferences" "kind:system preferences, kind:preferences" }
31 { "Presentations" "kind:presentations, kind:presentation" }
33 { $subheading "Date Keywords" }
34 "These can be included in the query expression to limit the age of documents returned:"
36 { "date:today" "$time.today()" }
37 { "date:yesterday" "$time.yesterday()" }
38 { "date:this week" "$time.this_week()" }
39 { "date:this month" "$time.this_month()" }
40 { "date:this year" "$time.this_year()" }
41 { "date:tomorrow" "$time.tomorrow()" }
42 { "date:next month" "$time.next_month()" }
43 { "date:next week" "$time.next_week()" }
44 { "date:next year" "$time.next_year()" }
46 { $subheading "Boolean Operators" }
47 "By default mdfind will AND together elements of the query string."
49 { "| (OR)" { "to return items that match either word, use the pipe character: " { $snippet "stringA|stringB" } } }
50 { "- (NOT)" { "to exclude documents that match a string: " { $snippet "-string" } } }
53 { "< and >" "\"less\" or \"more than\"" }
54 { "<= and >=" "\"less than or equal\" or \"more than or equal\"" }
58 "Return all files that have been modified today"
59 { $code "\"date:today\" mdfind" }
60 "Return all files that have been modified in the last 3 days"
61 { $code "\"kMDItemFSContentChangeDate >= $time.today (-3)\" mdfind" }
62 "Returns files with particular attributes"
63 { $code "\"com.microsoft.word.doc\" \"kMDItemContentType\" attr== mdfind" }
64 "Look for files with a particular file name"
65 { $code "\"Finding Joy in Combinators.pdf\" \"kMDItemFSName\" attr== mdfind" }
66 "Look for terms in documents"
67 { $code "\"Document cocoa.messages selector\" mdfind" }
68 "Return all files in the users home folder that have been modified in the last 3 days"
69 { $code "\"~\" [ \"kMDItemFSContentChangeDate >= $time.today (-3)\" mdfind ] with-directory" }
71 { $notes "This word uses the " { $link current-directory } " to restrict the search, choosing to search from the root ('" { $snippet "/" } "') if not set." } ;
74 { $values { "query" string } }
75 { $description "Similar to " { $link mdfind } ", but prints out the results as a list of " { $link pathname } " objects, allowing you to right-click and \"Open File\" if used with the " { $snippet "webbrowser" } " vocabulary." } ;
78 { $values { "path" "string or pathname" } }
80 "Lists the metadata attributes for the specified file."
82 { $snippet "mdls [-name attributeName] [-raw [-nullMarker markerString]] file ..." }
84 "The mdls command prints the values of all the metadata attributes associated with the files provided as an argument."
88 { $values { "flags" string } { "on|off" string } { "volume" string } { "seq" sequence } }
90 "Manage the metadata stores used by Spotlight."
92 { $snippet "mdutil [-pEsav] [-i on | off] mountPoint ..." }
94 "The mdutil command is useful for managing the metadata stores for mounted volumes."
98 { $values { "path" string } { "seq" sequence } }
100 "Import file hierarchies into the metadata datastore."
102 { $snippet "mdimport [-VXLArgn] [-d level | category] [-w delay] file | directory" }
104 "mdimport is used to test Spotlight plug-ins, list the installed plug-ins and schema, and re-index files handled by a plug-in when a new plug-in is installed."
108 { $values { "seq" sequence } }
109 { $description "Retrieves all the available kMDItemAttributes." } ;
112 { $description "Prints a table of all the available kMDItemAttributes." } ;