How to search all scrivener files??

What is the best way to do the following?

I have a document that has the phrase “fat bottomed girls” in it. How can I search, and find, this document when I have hundreds of scrivener files, each with many folders and sub-folders?

Spotlight on the Mac only searches the file name, not inside the text of the scrivener document.

How can I find my fat-bottomed girls?

Any ideas?

Thanks!

You’ll have to enter the mysteeeeerious and scaaaaaary world of the COMMAND LINE to do this quickly and easily. But FEAR NOT! I shall help you in your quest.

In /Applications/Utilities, you will find a program called Terminal. Don’t let the name scare you, it won’t send a message through time to Skynet and bring back a flesh-covered robot to kill you.

Probably not. Do I look like a time traveler to you? (Don’t answer that.)

Now, with the Terminal window open, paste this in (change the stuff between ""s, of course):

find ~/Documents -type f -exec grep -il “make the rockin world go round” {} ;

Your actual phrase will vary, but I advise keeping it short and avoiding any parts of the phrase that might contain punctuation; some of that stuff can affect how the search works. If you chose a good phrase, and if the grep command can parse .rtf files like I think it should, then you’ll see some output with your scrivener project’s name in it, ending in .scriv, followed by more path & file name(s). Just ignore the part past the .scriv, and you’ll have the location & name of your project.

I’m assuming that all your Scrivener projects are in your Documents folder. If not, delete the Documents word from above, leaving the ~/ part.

Fare well, and good hunting!

What version of OS X are you using? I tried testing some string searches that I know to be in certain projects and I was able to locate the project by typing in that string. This is on 10.8.

Maybe the Spotlight index needs to be rebuilt?


There are some geekier (non-GUI) ways to go about this as well, as the Mac UNIX environment has some rather powerful searching tools that go into the actual data rather than using an index. You could scour all of the ‘search.indexes’ files on your disk for a phrase. Copy and paste the following into Terminal, replacing SEARCHSTRING with whatever text you’re looking for, don’t remove the quotes around it though:

find ~ -name search.indexes -print0 | xargs -0 grep -F -i -l 'SEARCHSTRING'

That will locate every Scrivener search index within your home folder (everything, including trash) and then send that list of files to a search program that will scan for the literal phrase, case-insensitive, printing the name of each file that matches.

You’ll probably get a whole bunch of “Permission denied” messages (especially if you search the whole computer) that can be ignored. What you’ll be looking for are lines like this:

/Users/YourNameHere/Documents/Queen.scriv/Files/search.indexes

So from that we can see that ‘Queen.scriv’ is located in your user Documents folder.

Tips

  • If you want to search just external drives, change the ‘~’ to ‘/Volumes’. Search time will escalate quite a bit if you have something slow like a flash drive or optical disc mounted.
  • Change the ‘~’ at the beginning to ‘/’ to search everything, even external drives, but be prepared to maybe take a nap in the meanwhile. :slight_smile:

Thanks, Robert & Amber! I tried both methods, and while Amber’s is significantly faster, Robert’s finds data that is in snapshots but no longer in the files themselves. Good tools!

Naturally I immediately made both into Typinator shortcuts, with options to either type in the search string or paste what’s on the clipboard. :wink:

Now if I could only force Spotlight for OS 10.6.8 Snow Leopard to index my .scriv packages…