Table of Contents       9. AppleScript

9.3 Find by AppleScript

The most important feature in NeoFinder is certainly the Find function, as without it, your carefully cataloged data would be worthless. You can of course not only perform that Find with AppleScript, you can also access the results, the Found Items.

Simple Find

This sample asks NeoFinder to find every file or folder in every available catalog that contains the string “Star Trek” in any text field:

tell application "NeoFinder"
     find "Star Trek"
end tell

Simply paste it into a new document in Apples
Script Editor and run it.

Also, as a Find can take some time if you have a huge amount of catalogs, you may want to use the with timeout of statement to prevent errors from occurring.

After the Find is complete, you can access the attributes of all found items:

tell application "NeoFinder"
     with timeout of 2000 seconds -- remember: this might take more than the default 60 seconds!
          find "Star Trek"
     end timeout

     set numResults to found items amount
     repeat with i from 1 to numResults
          tell found item index i
               set myName to name
               set myPath to complete path
               set mySize to size
               set myKind to kind
          end tell
     end repeat
end tell

It is possible to limit the catalogs to be searched by adding the optional catalogs parameter with a list of catalog names.

tell application "NeoFinder 7.2"
     with timeout of 2000 seconds
          find "Paris" catalogs {"Photos 2016", "Photos 2017"}
     end timeout
end tell

This example will search only the two catalogs named "Photos 2016" and "Photos 2017". This is the actual name of the catalogs that NeoFinder displays in LIBRARY.

Complex Find

If you wish to add more complex find parameters, you can now use the new
run query command. This essentially gives you the complete set of powerful find parameters that the Find Editor of NeoFinder allows!

Here is how that looks like:

The actual query is a string in a custom XML format with a basic "MedoraQuery" entity. In this example, it will search for all items that have a MP3 comment that contains the text "Roger"

How do you find out what options you have?

Simply use the powerful Find Editor in NeoFinder!

1. Set up the search you are interested in with the
Find Editor in NeoFinder.

2. Save that search as a Smart Folder

3. Select that new Smart Folder, and use the context menu to reveal the ".query" file for it in the Finder

4. Open that text file in your favourite text editor

5. Copy over just the "
MedoraQuery" part to the Script editor, as in the example above.

That is it.

9.1 The NeoFinder AppleScript dictionary
9.2 The Scripts menu and folder
9.3 Find by AppleScript
9.4 Change the preferences of NeoFinder
9.5 Cataloging and updating
9.6 Use the Selection