Bonjour
Si je n'ai rien oublié, le code ci-dessous devrait régler le problème?
--[Script]
--
-- Initialiser les constantes
--
set label_Annuler to "Cancel"
set label_Continuer to "OK"
--
-- Demande de confirmation
--
display dialog "Mettre dans la corbeille les caches de Safari ?" buttons {label_Continuer, label_Annuler} ¬
default button 1 ¬
with icon caution
-- Ici, result est un 'record', pas une liste
--copy the result as list to {the button_pressed}
set button_pressed to button returned of result
if button_pressed is label_Annuler then
tell me to quit
end if
set p2Lib to (path to library folder from user domain as string)
--
-- Action !
--
tell application "Finder"
tell folder p2Lib
tell folder "Caches:com.apple.Safari:"
set someItems to {"WebKitCache", "WebKit", "TabSnapshots", "fsCachedData", "Cache.db", "Cache.db-shm", "Cache.db-wal"}
repeat with anItem in someItems
try
delete item anItem
end try
end repeat
end tell -- folder "Caches:com.apple.Safari:"
tell folder "Safari"
try
delete every item of folder "Databases"
end try
set someItems to {"Favicon Cache", "RemoteNotifications", "Touch Icons Cache", "Downloads.plist", "History.db", "History.db-lock", "History.db-shm", "History.db-wal", "LastSession.plist", "PerSitePreferences.db", "PerSitePreferences.db-shm", "PerSitePreferences.db-wal", "RecentlyClosedTabs.plist", "PerSiteZoomPreferences.plist", "SearchDescriptions.plist", "TopSites.plist", "UserMediaPermissions.plist", "Template Icons:CacheSettings.plist"}
repeat with anItem in someItems
try
delete item anItem
end try
end repeat
try
delete every file of folder "Touch Icons Cache"
end try
end tell -- folder "Safari"
tell folder "Cookies"
set someItems to {"com.apple.Safari.SearchHelper.binarycookies", "com.piriform.ccleaner.binarycookies", "Cookies.binarycookies", "SafariNotificationAgent.binarycookies"}
repeat with anItem in someItems
try
delete item anItem
end try
end repeat
end tell -- folder "Cookies"
try
delete every file of folder "Safari:LocalStorage"
end try
try
delete every file of folder "WebKit:LocalStorage"
end try
end tell -- p2Lib
end tell
--[/Script]
Vérifiez que je n'ai rien oublié.
Si c'est bien le cas vous pourriez avantageusement remplacer le script par:
--[Script]
--
-- Initialiser les constantes
--
set label_Annuler to "Cancel"
set label_Continuer to "OK"
--
-- Demande de confirmation
--
display dialog "Mettre dans la corbeille les caches de Safari ?" buttons {label_Continuer, label_Annuler} ¬
default button 1 ¬
with icon caution
-- Ici, result est un 'record', pas une liste
--copy the result as list to {the button_pressed}
set button_pressed to button returned of result
if button_pressed is label_Annuler then
tell me to quit
end if
set p2Lib to (path to library folder from user domain as string)
--
-- Action !
--
tell application "System Events"
tell folder p2Lib
tell folder "Caches:com.apple.Safari:"
set someItems to {"WebKitCache", "WebKit", "TabSnapshots", "fsCachedData", "Cache.db", "Cache.db-shm", "Cache.db-wal"}
repeat with anItem in someItems
try
delete disk item anItem
end try
end repeat
end tell -- folder "Caches:com.apple.Safari:"
tell folder "Safari"
try
delete every disk item of folder "Databases"
end try
set someItems to {"Favicon Cache", "RemoteNotifications", "Touch Icons Cache", "Downloads.plist", "History.db", "History.db-lock", "History.db-shm", "History.db-wal", "LastSession.plist", "PerSitePreferences.db", "PerSitePreferences.db-shm", "PerSitePreferences.db-wal", "RecentlyClosedTabs.plist", "PerSiteZoomPreferences.plist", "SearchDescriptions.plist", "TopSites.plist", "UserMediaPermissions.plist", "Template Icons:CacheSettings.plist"}
repeat with anItem in someItems
try
delete disk item anItem
end try
end repeat
try
delete every file of folder "Touch Icons Cache"
end try
end tell -- folder "Safari"
tell folder "Cookies"
set someItems to {"com.apple.Safari.SearchHelper.binarycookies", "com.piriform.ccleaner.binarycookies", "Cookies.binarycookies", "SafariNotificationAgent.binarycookies"}
repeat with anItem in someItems
try
delete disk item anItem
end try
end repeat
end tell -- folder "Cookies"
try
delete every file of folder "Safari:LocalStorage"
end try
try
delete every file of folder "WebKit:LocalStorage"
end try
end tell -- p2Lib
end tell
--[/Script]
Avec ce dernier, l'effacement étant effectué par System Events, les éléments supprimés n'encombreront pas la poubelle.
Yvan KOENIG (VALLAURIS, France) mardi 22 décembre 2020 15:35:51
_______________________________________________
Applescript_fr mailing list
Applescript_fr@???
http://listes.patpro.net/mailman/listinfo/applescript_fr