Backup as zip archive


To be honest I pondered on this but I have no idea how to create a zip archive in this way - there seem to be no public Apple APIs to do this. I know certain other apps do it, but I don’t know how. Back when I used to program on Windows (eek), it was really easy because there were some free public libraries to do this. So the answer is: maybe, but it’s not a priority. :slight_smile:


The Path Finder crew had to end up embedding the StuffIt engine to do all of their compression, because Apple provides no access to their much faster ZIP system.

Then I guess the answer is no for the foreseeable future… :slight_smile:


Would it not be possible to use the zip command from the command line? If you can supply the file name, its path, and a date/time string, you should be able to execute a “shell” command from inside the app.

Just a thought.

I looked it up and here is how to do it with the zip command:

zip /path/to/ /path/to/Tutorial.scriv/*

I thought the compression might be meager upon first glance, but upon checking and rechecking, it looks to be 30-40%. Not so bad, and I imagine it depends on the type of files in the scriv.

Thanks for this, Rick - I’ll put it on the “possibilities” list (ie. no guarantee for beta 3 or 1.0, but a possibility :slight_smile: ).

Okay, I have this mostly working. However, because .scriv files are packages - and therfore folders as far as the zip utility is concerned - the zip utility requires the -r option to copy everything inside the folder (package). However, doing this with a whole path (eg. /users/myname/somefile.scriv) copies all the folders from the path into the zip file (so that you would have the “users” and “myname” folders inside the zip file).

If anyone knows how to get the contents inside .scriv into the zip without the other folders, please let me know…


EDIT: the “/*” thing doesn’t seem to work in Cocoa…


Can you not change the working directory in Cocoa? Then you would only need to supply the name of the .scriv file with the -r flag. All entries would be relative to the current location.

zip -r backup.scriv

unzip -l 0 09-21-06 21:00 backup.scriv/ 28 09-21-06 21:00 backup.scriv/.LSOverride 0 09-21-06 21:00 backup.scriv/10.rtfd/ ... and so forth

Otherwise, I do not know of a way. The -j flag junks directory information, but that also means it junks the .scriv directory info too, putting everything into the root level of the archive.

Nope, just pining for the ffjords… Er, which is to say, I’ve fixed this up and it’s now implemented for beta 3. A big thank you to Rick for the command line info which I had overlooked (and which was easy to implement thanks to the fact that I looked into this stuff recently anyway for implementing MultiMarkdown).

All the best,

P.S. I seem to be cross-posting with AmberV - yes, I missed a simple -setCurrentDirectoryPath: setting, which is all I needed to get this working correctly.

Actually, I put the /path/to paths in above to be nice, but, they cause problems. When I proved to myself this works, I actually did what Av said, which was to “cd” into the path with the .scriv’s in Terminal. Trying the zip command with the -r switch, after cd’ing, it works fine. I’m sorry to have confused the group…

By the way, the -l switch on my Mac with the latest version of OS/X is for converting linefeeds or something, in the zip command. If you want to list the contents, I think you need to use the UNzip command with -l. I.e.:

>unzip -l

Av, did you mean to type unzip?

Dueling posts!! 8) Seems you already got it! Thanks!

A question: does your implementation include the date/time in the filename of the zip, I wonder?

Yes, sorry about that. I meant unzip -l. I fixed the main post.

That’s up to you. :slight_smile: The zip backup feature is just an extension of the current “Backup to…” feature. So you specify the name and location to which to save the zip file. Yes, I know this isn’t like some other apps that run automatic backups, but I personally like a little more control. That said, I have added the date and time to be automatically appended to the file name that appears in the Save As… dialogue box.

Thank you, and that is very good news. Nice to have that date/time stamp in there as the default.