--(SCRIPT keep_clean_prefs.app]
(*
To keep clean preferences files.
In your userAccount's Preferences folder,
create a subfolder named "safe_Prefs"
Store in this folder clean duplicates of the preferences files subject to corruption.
Save this script as an Application Bundle where you want.
Why not in your Applications folder?
Open the System Preferences Pane "Account"
Click on the "Login" tab.
Drag and drop the script's icon onto the window to add it to the list of login items.
On every boot process, the script will be run so it will install the clean prefs.
Of course, if you change something to the prefs and know that the file is clean,
duplicate the new version to the safe_prefs folder.
Yvan KOENIG (26 mai 2008)
*)
on run
run mon_script
end run
script mon_script
set p2prefs to path to preferences from user domain
set p2Safe to (p2prefs as Unicode text) & "safe_Prefs:"
if p2Safe does not end with ":" then set p2Safe to p2Safe & ":"
tell application "Finder"
if exists folder p2Safe then
set liste to items of folder p2Safe
repeat with p in liste
if class of p is folder then
set liste2 to items of p
if liste2 is not {} then
set p2prefs2 to ((p2prefs as text) & name of p & ":") as alias
repeat with p2 in liste2
duplicate (p2 as alias) to p2prefs2 with replacing
end repeat
end if
else
try
duplicate (p as alias) to p2prefs with replacing
end try
end if
end repeat
end if -- exists folder…
end tell
end script
--[/SCRIPT]
I guess that it would be a good idea to drop the Finder use.
When I wrote it, I didn't use Do Shell Script and there was no enabled Duplicate function in System Events.
Happily, thanks to the run script tip, it behave quickly as is.