Getting Finder results into LiveCode

Richard Gaskin ambassador at fourthworld.com
Mon Jan 11 11:03:02 EST 2016


Francis Nugent Dixon wrote:
> I use “cmd F” to find documents on my computer
> (never got round to using Spotlight).
> Is there a way to get the results of such a “Find”
> inside a Rev stack ? Anybody done this ???
> I am a buggar for backups, and for one original, I
> have copies on several of my external disks.
> I want to update all the copies of a file that I just
> modified, and by hand, it’s a pain !
>
> And just in case I haven’t got enough, is there a way
> to display in a liveCode stack the results of a “Get Info”
> from the finder ?
>
> I seem to spend half my life in "housekeeping"

If the larger goal here is to manage backups, I can describe what I do 
these days and although how people manage their backups is a very 
personal choice hopefully some of this will be useful:

With backups I have two goals:

- Redundancy, recognizing that drives fail
- Versioning, recognizing that the latest version may not always
               be the one I want

I use two mechanisms for versioning, and rsync for everything else.

I happen to use ownCloud for syncing not only my LC Plugins folder but 
also the folder containing my work files (and a few others).  Dropbox, 
Google Drive, and Time Machine also provide versioning, so which one is 
used is often less important than that at least one of them is used. 
ownCloud is more flexible than the others, so while it's more work to 
set up I need a server in the office for testing anyway, so it was 
convenient enough to add ownCloud to that.

So while ownCloud keeps my Ubuntu workstation, Ubuntu laptop, and OS X 
workstation in sync with a versioned repository through my local server, 
I also have Time Machine on my Mac to have a second copy versioned 
through different means.

With this, with the various synced machines I have two versioned 
archives and three current copies of all data.

But all of this is in my office, and I live in an earthquake-prone area. 
  Given that portable HDDs are available at about US$50/TB, I have four 
of them, and each night I sync my work folders and email to one of those 
drives, and take it home to bring the next one in the following day. 
Periodically I also save a complete archive of work files as a snapshot 
(space being cheaper than time).  So even if my office is destroyed and 
some of the offsite drives fail, the worst case leaves me with at least 
one complete copy of all current and archived files.

The key to being able to conveniently backup to a portable drive has 
been rsync.  It's a very smart algo that automatically does a lot of 
what I think I was reading in your post:

With a given source folder and a destination folder, it can recursively 
go through all folders and compare all files, skipping any where the mod 
date and file size are the same (there's also an option to force a 
checksum, but that's usually not needed since it's extremely rare that a 
file will change in a way that leaves the size and mod date the same).

This is quite efficient in itself, but it gets better:  once rsync finds 
a file that needs replacing, it compares segments of the file and only 
copies the segments that have changed.

All this comes together to make a solution that's about as efficient as 
it can be, and very easy to write into a text file on your drive that 
you can call whenever you need it, e.g.:

rsync -av /Users/username/WorkFolder/  /Volumes/backupdrive/WorkFolder/

rsync has many options (it's a deeply flexible tool), but the ones shown 
here are:

  a: archive mode, preserves time stamps, user and group ownership,
     and other file attributes useful to make a true mirror of the
     source.

  v: verbose mode, displays each action in Terminal as it's running;
     most of the time I don't care, but it's interesting to watch.

If backing up over a network it can be useful to add a z option there, 
which uses gzip compression for each packet copied to reduce 
transmission time.

The end result is half a dozen drives with complete copies of the entire 
directory structure of all useful files, with time stamps preserved to 
make a truly complete and multiply redundant collection of backups.

rsync is preinstalled on OS X and Linux, and can be used on Windows when 
the free Cygwin package is installed.

There are many tutorials on using rsync on OS X for backups - here's 
just one:
<https://www.haykranen.nl/2008/05/05/rsync/>

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list