property stringLib : load script "MacHD:AppleScriptÅ Utilities:Sample Scripts:AppleScript Samples:Libraries:stringLib" property DebugFilesCount : 0 property ret : ASCII character 13 -- do ya remeber these times ? 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 tell application "Scriptable Text Editor" to set text of window 1 to "" end if end DebugStr on SniffDataFromFolder(withthat) tell application "Finder" set hereto to {} set willi to count each item of alias withthat set hereto to hereto & (alias withthat as reference) -- first item is the folders ref DebugStr(ret & (" Counted " & willi as text) & " items in " & withthat as text) of me repeat while willi > 0 set ListLabel to get label index of item willi of alias withthat set hereto to hereto & ListLabel set ListEntry to name of item willi of alias withthat set hereto to hereto & ListEntry set Datum to modification date of item willi of alias withthat set hereto to hereto & Datum DebugStr(ListLabel & " : " & (ListEntry as text) & " ; " & Datum as text) of me set willi to willi - 1 end repeat end tell return hereto end SniffDataFromFolder (* Nice one. not As I wanted itä but so it's the easier way The returned list gives us all infos we need. The items class bacause it's not a reference and the mod date. It's on you to read it out correctly- That's an easy job. Now it's this rsrc-sturcture from strings : item 1 is special then a double packed list follows : name,date,name,date,... *) (* Operate takes two files from match. This means you have to pass in two file references from existing files operate(thisname, thisdate, fromcontainer, tocontainer) the infos for date and label from tocontainer are not used at the moment. let's see what future brings up *) on operate(thisone, date1, thislabel, infolder, withfolder) tell application "Finder" (* It's already clear that in withfolder is a item with the same name. otherwise we won't be here. compare class and date . and then do something infolder withfolder are refs, thisone is a name, data and label are date and int *) DebugStr("- Operate " & thisone & " of " & (infolder as reference)) of me set Heute to current date set date2 to modification date of item ((withfolder as alias) & thisone as text) if (thislabel Ñ 6) then -- file is type of sync2del DebugStr((" ä " & (thisone as text) & " ist 6/7 und vorhanden auf BackupVol")) of me if date1 > date2 then DebugStr((" ä " & (thisone as text) & " wird umkopiert")) of me duplicate item ((infolder as text) & thisone as text) to withfolder with replacing set label index of item ((infolder as text) & thisone as text) to 7 set label index of item ((withfolder as text) & thisone as text) to 7 end if if date1 < (Heute - (21 * days)) then DebugStr((" ä " & (thisone as text) & " wird gel–scht und gelocked")) of me set label index of item ((withfolder as text) & thisone as text) to 6 set comment of item ((withfolder as text) & thisone as text) 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 ((withfolder as text) & thisone as text) to true delete item ((infolder as text) & thisone as text) else if date1 < (Heute - (7 * days)) then DebugStr((" ä " & (thisone as text) & " wird auf 6 gelabelled")) of me set label index of item ((infolder as text) & thisone as text) to 6 -- mark the future action set label index of item ((withfolder as text) & thisone as text) to 7 -- change only when del ! end if else if (thislabel = 5) then -- file is type of sync2stay DebugStr((" ä " & (thisone as text) & " ist 5 und vorhanden auf BackupVol")) of me if date1 > date2 then DebugStr((" ä " & (thisone as text) & " abgeglichen " & infolder & " nach " & withfolder)) of me duplicate item ((infolder as text) & thisone as text) to withfolder with replacing set label index of item ((infolder as text) & thisone as text) to 5 set label index of item ((withfolder as text) & thisone as text) to 5 else if date2 < date1 then DebugStr((" ä " & (thisone as text) & " abgeglichen " & withfolder & " nach " & infolder)) of me duplicate item ((withfolder as text) & thisone as text) to infolder with replacing set label index of item ((infolder as text) & thisone as text) to 5 set label index of item ((withfolder as text) & thisone as text) to 5 else DebugStr((" ä " & (thisone as text) & " war identisch auf beiden Volumes")) of me set label index of item ((infolder as text) & thisone as text) to 5 set label index of item ((withfolder as text) & thisone as text) to 5 end if else -- it's existent but not labelled (cant be 4, but can 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 DebugStr((" ä " & (thisone as text) & " hatte ein Label 0 - 3(4 !possible)")) of me if date1 > date2 then DebugStr((" ä " & (thisone as text) & " abgeglichen " & infolder & " nach " & withfolder)) of me duplicate item ((infolder as text) & thisone as text) to withfolder with replacing else if date2 < date1 then DebugStr((" ä " & (thisone as text) & " abgeglichen " & withfolder & " nach " & infolder)) of me duplicate item ((withfolder as text) & thisone as text) to infolder with replacing else DebugStr((" ä " & (thisone as text) & " war identisch auf beiden Volumes")) of me end if set label index of item ((infolder as text) & thisone as text) to label index of infolder set label index of item ((withfolder as text) & thisone as text) to label index of infolder end if end tell end operate on match(fromhere, tothere) -- give it a SniffDataFromFolder LIST !!! no aliasses ! tell application "Finder" set fromcontainer to (item 1 of fromhere) -- its a ref set tocontainer to (item 1 of tothere) -- its a ref set fromcount to count fromhere set therecount to count tothere repeat while fromcount > 1 (*SniffDataFromFolder has this order : folder in question, repeated : Label,Name only, mod date *) set thislabel to (item (fromcount - 2) of fromhere) set thisname to (item (fromcount - 1) of fromhere) set thisdate to (item fromcount of fromhere) -- OLD set thislabel to get label index of item ((fromcontainer as text) & thisname) if (class of item ((fromcontainer as text) & thisname as text) is not folder) then if (thislabel is not 4) then if (thisname is in tothere) then -- here starts another level of inheritance operate(thisname, thisdate, thislabel, fromcontainer, tocontainer) of me else -- has to be a simple copy DebugStr(("- Operate " & thisname as text) & " Label !4 _and_not_in_Dest => Duplicate") of me duplicate item ((fromcontainer as text) & thisname as text) to tocontainer with replacing set label index of item ((fromcontainer as text) & thisname as text) to label index of fromcontainer set label index of item ((tocontainer as text) & thisname as text) to label index of fromcontainer end if else DebugStr((" - " & (thisname as text) & " hatte Label 4 and was SKIPPED")) of me end if else -- oops. it's again a container do only if parent is in sync chain if (thislabel > 4) then DebugStr((" - " & (fromcontainer as text) & thisname as text) & " going down ü (>4)") of me set digservfolder to {} set digservfolder to SniffDataFromFolder(((fromcontainer as text) & thisname as text) as text) of me set digdestfolder to {} set digdestfolder to SniffDataFromFolder(((tocontainer as text) & thisname as text) as text) of me match(digservfolder, digdestfolder) of me set label index of item ((tocontainer as text) & thisname as text) to label index of item ((fromcontainer as text) & thisname as text) else DebugStr(ret & (" - " & (fromcontainer as text) & thisname as text) & " skipped ü (<=4)") of me end if end if set fromcount to fromcount - 3 --so now we take the next file end repeat end tell end match on run tell application "Finder" 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 "" set jones to {} set jones to SniffDataFromFolder("MacHD:") of me set indiana to {} set indiana to SniffDataFromFolder("DeTeen:") of me match(indiana, jones) of me tell application "Scriptable Text Editor" to close window 1 saving yes saving in alias "MacHD:Desktop Folder:DebugMessages" duplicate alias "MacHD:Desktop Folder:DebugMessages" tell application "Scriptable Text Editor" to quit end tell end run