(* (C) Hado Hein 1998, Berlin, FRG parts (C) Apple Computer Inc. - published scripting samples of MacOS 7 & 8 to sync and move files from a small voloume (src) to a big backup volume (dest) set lables to following label 7 (last) on both systems to "Synchronized" label 6 on small volume to "is to be deleted" label 6 on big volume to "is del on small" label 5 on both volume to "sync to stay" label 4 on small volume to "no sync" Functionality as following : You have a small disk (Laptop e.g) and a big disk (desktop e.g.). So you produce some files that need to be synchonized with the big volume (bills e.g.). You can sync them - but you don^t need them on the small volume anymore. You have other files (homepage e.g.) you just need to sync. As above you might generate a file in that folder "on the road" an need to sync it to the big volume. Label filing does it. The small volume is scanned for folders that have labels (a top level scan). ONLY in THESE folders is work done. Label filing recursively scans all items and operates on them. There are some really picky rules : Any file in these folders (beneath top level) that has NO label will be backed up to the corresponding folder on the big volume. Both files (src/copy) get the label of the containingfolder of the small volume that holds the file. If the Label is 5 (Sync to stay) the files are synced. This means not only a backup if changed on small; Also a update if changed on big (Homepage e.g.) If the Label is 6 or 7 the files will be backed up to big if they're changed. (scenario: you set the label manually or you edited a already backed up file). The files with label 6/7 will disappear on the small volume some day ! (e.g. written bills on the road) Rules are the following: First a file gets label 7 (sync to del). This marks that there is going on something with this files. 7 days after the last change a file gets label 6 (will be del). 21 days after last change the file will be deleted. the copy on the big volume is set to locked and label 6 (is del on small), also there is inserted a comment in the get info window. This is done for safety because of the fact that there is no more copy of this file on small. Also (not implemented yet) there will be a sync back for labelled folder from big to small. (e.g. hompage / label 5 ) where a new file is made on the big volume. Important : On top level a folder has to be marked. (folder x of disk y) - after top level it is scanned recursively until a label 4 (end sync) is found *) property Platten : {} -- store the available disks property Tueten : {} -- actual folderset that the script is working on property topLevel : {} -- the top list of folders on a disk property SearchDepth : 3 property ret : ASCII character 13 -- do ya remeber these times ? property stringLib : load script "MacHD:Development:AppleScript Samples:Libraries:stringLib" -- string lib is found on dev cd / scripting samples on quit tell application "Finder" speak "label filing has quit" end tell continue quit end quit on DebugStr(theText) tell application "Scriptable Text Editor" to make new paragraph with data (theText) if (count characters of window 1 of application "Scriptable Text Editor") > 30000 then set text of window 1 of application "Scriptable Text Editor" to "" end if end DebugStr on SniffIn(alist) tell application "Finder" set re to {} repeat with I in alist DebugStr(("Sniff is looking at : " & I as text)) of me if (get label index of (I as alias)) Ñ 5 then set re to re & I DebugStr(("Sniff took : " & I as text)) of me end if end repeat return re end tell end SniffIn on operate(thisone, onthat) tell application "Finder" set lab to get label index of (thisone as alias) set x to (thisone as alias) as string set x to getEnd of stringLib from x at ":" set x to (onthat as string) & x set isx to exists item (x as text) DebugStr(("Operate " & thisone as text)) of me if ((lab Ñ 6) and isx) then -- file is there and type of sync2del set date1 to modification date of (thisone as alias) set date2 to modification date of (x as alias) set Heute to current date DebugStr(((thisone as text) & " ist 6/7 und vorhanden auf BackupVol")) of me if date1 > date2 then duplicate thisone to (x as alias) with replacing set label index of item (thisone as alias) to 7 set label index of item (x as alias) to 7 DebugStr(((thisone as text) & " wurde umkopiert")) of me end if if date1 < (Heute - (21 * days)) then set label index of item (x as alias) to 6 set comment of item (x as alias) to (Heute & " wurde dieses File als " & thisone as string) & " durch LabelFiling gel–scht" -- english : Today date File x was deleted by LabelFiling set locked of item (x as alias) to true delete (thisone as alias) DebugStr(((thisone as text) & " wurde gel–scht und gelocked")) of me else if date1 < (Heute - (7 * days)) then set label index of item (thisone as alias) to 6 DebugStr(((thisone as text) & " wurde auf 6 gelabelled")) of me end if else if ((lab = 5) and isx) then -- file is there and type of sync set date1 to modification date of (thisone as alias) set date2 to modification date of (x as alias) set Heute to current date DebugStr(((thisone as text) & " ist 5 und vorhanden auf BackupVol")) of me if date1 > date2 then duplicate (thisone as alias) to (x as alias) with replacing set label index of item (thisone as alias) to 5 set label index of item (x as alias) to 5 DebugStr(((thisone as text) & " abgeglichen " & (disk of thisone as text) & " nach " & (disk of x as text))) of me else if date2 < date1 then duplicate (x as alias) to (thisone as alias) with replacing set label index of item (thisone as alias) to 5 set label index of item (x as alias) to 5 DebugStr(((thisone as text) & " abgeglichen " & (disk of x as text) & " nach " & (disk of thisone as text))) of me else DebugStr(((thisone as text) & " war identisch auf beiden Volumes")) of me end if else if (not isx) then -- file is new on small / get status of folder set fola to get label index of (folder of thisone) set newPos to (folder of thisone as text) set newPos to getEnd of stringLib from newPos at ":" set newPos to (onthat as string) & newPos duplicate thisone to (newPos as alias) set label index of thisone to fola set label index of file (x as alias) to fola DebugStr(((thisone as text) & " ist NICHT vorhanden auf BackupVol")) of me else -- it's existent but not labelled (cant be 4) - so it is synced and then marked like the folder -- that's for files that are new in marked folders -- happens mostly in the first time when starting to use label filing set fola to get label index of (folder of thisone) set date1 to modification date of (thisone as alias) set date2 to modification date of (x as alias) set Heute to current date DebugStr(((thisone as text) & " hatte kein Label (4 !possible)")) of me if date1 > date2 then duplicate (thisone as alias) to (x as alias) with replacing DebugStr(((thisone as text) & " abgeglichen " & (disk of thisone as text) & " nach " & (disk of x as text))) of me else if date2 < date1 then duplicate (x as alias) to (thisone as alias) with replacing DebugStr(((thisone as text) & " abgeglichen " & (disk of x as text) & " nach " & (disk of thisone as text))) of me else DebugStr(((thisone as text) & " war identisch auf beiden Volumes")) of me end if set label index of item (thisone as alias) to fola set label index of item (x as alias) to fola end if end tell end operate on WorkThatDown(afifoli) tell application "Finder" set topContens to {} repeat with J in afifoli if ((get label index of (J as alias)) Ç 4) then if (class of J is not folder) then DebugStr(("Work down Ç 4 (item no folder): " & J as text)) of me operate(J, startup disk) of me else DebugStr(("Work down Ç 4 (item is folder) : " & J as text)) of me --repeat with K in (SniffIn(J) of me) repeat with K in (every item of (J as alias)) -- do it this way to get files in folders that are not labelled DebugStr((("Work down Ç 4 (item IN folder) : " & J as text) & " / " & K as text)) of me if ((get label index of (K as alias)) Ç 4) then if (class of K is folder) then WorkThatDown(K) of me else operate(K, startup disk) of me end if end if end repeat end if end if -- sync back mit folder auf big - there might be a file with label 5 that is not on small - then put it there -- list of folder lesen, die gelabelten (nur die !) ¸berpr¸fen ob auf dem kleinen volume - wenn nicht, und nur dann, dahin kopieren -- ICH HAB DA KEINEN BOCK DRAUF. DAS ist so viel hackerei end repeat end tell end WorkThatDown tell application "Finder" set Platten to list disks tell application "Scriptable Text Editor" to save window 1 in alias "MacHD:Desktop Folder:DebugMessages" tell application "Scriptable Text Editor" to set size of text of window 1 to 9 tell application "Scriptable Text Editor" to set text of window 1 to "" repeat with I in Platten if (get startup of disk (I as string)) = false then DebugStr(("Platte : " & I as text) as text) of me set topLevel to SniffIn(every folder of disk (I as string)) of me WorkThatDown(topLevel) of me end if end repeat repeat with I in list disks if not (local volume of disk (I & ":")) then put away ((I & ":") as alias) end if end repeat tell application "Finder" of machine "Serving DevoTeens" to shut down shut down end tell