Searching across backups?

mr
mrsf
Posts: 12
Joined: Fri May 25, 2018 11:31 am
Platform: Mac

Mon Jul 23, 2018 6:33 pm Post

I am completely missing a passage in my current version. I remember writing it but must have inadvertently deleted it, I have the daily backups, a bunch of them on drop box. Aside from unzipping and reopening every single file (not sure when I actually wrote it, probably a month ago...), is there a way to search for a specific word across the zip files?

Edited to add...I solved this by finding the passage under a different chapter, in the wrong place. Must have been a cut/paste incident! Still this would be a good question for future reference.

User avatar
kewms
Posts: 7611
Joined: Fri Feb 02, 2007 5:22 pm
Platform: Mac

Mon Jul 23, 2018 9:45 pm Post

Sorry, ZIP files are not searchable.

(The reason is that the compression algorithm is effectively a form of encryption. ZIP files do not contain human readable text.)

Katherine
Scrivener Support Team

User avatar
devinganger
Posts: 2681
Joined: Sat Nov 06, 2010 1:55 pm
Platform: Mac, Win + iOS
Location: Monroe, WA 98272
Contact:

Tue Jul 24, 2018 7:36 am Post

kewms wrote:Sorry, ZIP files are not searchable.

(The reason is that the compression algorithm is effectively a form of encryption. ZIP files do not contain human readable text.)


Sorry, I lost my roll against pedanticism.

ZIP files *are* searchable but the software has to take the extra step to de-compress them somewhere to do so (usually in memory or a temporary file) so it can search the plainstream. And compression is not the same as encryption; it is a cypher and the resulting stream is not human-readable, but because it is trivially reversible without a key it's not encryption.
--
Devin L. Ganger
Not a L&L employee; opinions are those of my cat
Life has a way of moving you past wants and hopes -- Kevin Flynn

mr
mrsf
Posts: 12
Joined: Fri May 25, 2018 11:31 am
Platform: Mac

Sun Jul 29, 2018 2:09 pm Post

kewms wrote:Sorry, ZIP files are not searchable.

(The reason is that the compression algorithm is effectively a form of encryption. ZIP files do not contain human readable text.)

Katherine


I figured as much. Thank you!

mr
mrsf
Posts: 12
Joined: Fri May 25, 2018 11:31 am
Platform: Mac

Sun Jul 29, 2018 2:10 pm Post

devinganger wrote:
kewms wrote:Sorry, ZIP files are not searchable.

(The reason is that the compression algorithm is effectively a form of encryption. ZIP files do not contain human readable text.)


Sorry, I lost my roll against pedanticism.

ZIP files *are* searchable but the software has to take the extra step to de-compress them somewhere to do so (usually in memory or a temporary file) so it can search the plainstream. And compression is not the same as encryption; it is a cypher and the resulting stream is not human-readable, but because it is trivially reversible without a key it's not encryption.


Not exactly sure what you are saying here. I am guessing that the summary is that the software does not support this. Thank you for your response.

User avatar
AmberV
Posts: 24887
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Ourense, Galiza
Contact:

Sun Jul 29, 2018 3:44 pm Post

It takes a program that is designed to work with archived and compressed formats to search across them, is the point being made. Such programs do exist; on Windows I’m aware of a tool called PowerGrep (or something like that), which can search across .zip files for text phrases found within the files inside the .zip. I’m not sure of anything GUI-friendly for Mac that can do it, though. There may well be something, I’m just familiar with such tools and since I tend to drop to the command-line for this kind of stuff.

Geek Level Stuff Follows…

As to that, we have a handy tool that ships with the Mac called zgrep, that can scan a .zip file’s contents and located string matches within it, using the same search syntax available to the stock grep. Since Scrivener projects are packaged folders with many files within them (and the internal Zip directory tree will reflect that), you need to use the -R flag for recursive searching. For example:

Code: Select all

zgrep -R 'phrase to find' MyProject.bak1.zip


Now to scan a whole batch of zip files, you need to produce a list of .zip files and search each one individually (the -R recursion flag conflicts with a glob list, like ‘MyProject*’). Here is how you would locate which backups contain ‘phrase to find’, from all of the backups created for a project named “MyProject” (run this from the backup folder, otherwise change the ‘.’ to the full path of the backup folder, which can be copied as text from the Backup preference pane):

Code: Select all

find . -name 'MyProject*zip' -print0 | xargs -0 zgrep -R 'phrase to find'


The result of this is useful in that it doesn’t go in and pinpoint every little internal XML and RTF files that might contain the phrase. Rather it will simply state that “Binary file X matches”. From that you now should know which .zip files contain the phrase.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles