Hatte mal wieder keine Lust ins Bett zu gehen und dabei ist dann das hier heraus gekommen:
(**
Installation:
1. Wenn Du es das erste mal startest, erzeugt es einen Ordner mit dem Namen "SyncFolders_Script_aliases" auf deinem Start-Volumen und öffnet diesen.
2. In diesen Ordner ziehst Du zunächst Aliase der Quell-Ordner (ja Du kannst mehrere Ordner in einen Zielordner synchronisieren).
3. Diese Ordner-Alias bennenst Du um in SOURCE.. irgendwas, wichtig ist nur, dass SOURCE am Anfang steht
4. Dann erstellst Du da noch einen Alias deines Zielordners, den Du DESTINATION irgendwas nennst
Dann nur noch starten und das Skript legt los =)
Wie es funktioniert?:
Die Dateien werden an Hand von md5 Prüfsummen unterschieden. Jede Dateien, deren md5-Prüfsumme mit denen der Dateien im Zielordner nicht übereinstimmt, wird umbenannt, nach dem Schema (+OUT<aktuelles Datum>) und dann kopiert. Sollte es beim Kopieren zu Problemen kommen, wird die Datei wieder "zurück-benannt" und das Skript läuft weiter. Am Ende erscheint in dem Fall aber eine Fehlermeldung.
In dem Skript Ordner wird zudem ein Datei log.txt geführt, in der dann bei jedem Start geschrieben wird, wie viel wohin kopiert wurde und ob es Fehler gegeben hat...
**)
set script_folder to "SyncFolders_Script_aliases"
set copycount to 0
set copiedpaths to ""
set errorpaths to ""
checkup(script_folder)
tell application "Finder"
set alias_folder to folder script_folder of startup disk
set source_aliases to (every alias file of alias_folder whose name starts with "SOURCE")
set destination_alias to (every alias file of alias_folder whose name starts with "DESTINATION")
end tell
set destination_files to md5_list(item 1 of destination_alias)
set source_files to {}
repeat with i from 1 to count of source_aliases
set source_files to source_files & md5_list(item i of source_aliases)
end repeat
-- assume that all sources are new sources
set newsources to source_files
repeat with destination_file in destination_files
set b to md5 of destination_file
repeat with source_file in source_files
if md5 of source_file = b then
--finally only new sources will stay in the newsources list
set newsources to delete_from_list(source_file, newsources)
end if
end repeat
end repeat
set erroronmove to false
set prestring to "OUT+" & (do shell script "date +%Y%m%d")
repeat with newsource in newsources
set current_file to MacOSPath of newsource
tell application "Finder" to set current_file_name to (name of current_file)
--If the would be files already named "OUT+..:" that are NOT in the destination path
--these would no be copied
--if current_file_name does not start with "OUT+" then
set current_file to rename_file(current_file, prestring, current_file_name)
try
tell application "Finder"
set copiedfile to duplicate current_file to (original item of (item 1 of destination_alias)) as alias
set copycount to copycount + 1
set copiedpaths to copiedpaths & (POSIX path of (copiedfile as alias)<