Re: How to delete extraneous plist files via AppleScript
Re: How to delete extraneous plist files via AppleScript
- Subject: Re: How to delete extraneous plist files via AppleScript
- From: Axel Luttgens <email@hidden>
- Date: Thu, 13 Jan 2011 00:36:30 +0100
Le 12 janv. 2011 à 22:12, Barry Fass-Holmes a écrit :
> Hello,
>
> The script below compiles and executes without returning any errors, but does not produce the desired outcome during testing.
>
> The desired outcome is to move extra plist files for the weather widget to the Trash. Such files contain an extra extension consisting of a variable combination of characters and numbers. An example is
>
> widget-com.apple.widget.weather.plist.r2wmTrw
>
> This symptom is discussed at http://discussions.apple.com/thread.jspa?messageID=11616688�
>
> What have I done improperly in this AppleScript?
>
> -- Get current user's name
> tell application "System Events"
> set currentUser to (name of current user)
> end tell
>
> -- Check downloads folder and move extra weather widget plist files to the trash
>
> tell application "Finder"
> try
> delete (every file of folder "Preferences" of folder "Library" of currentUser of folder "Users" whose name contains "widget.weather" and name extension is not "plist")
> end try
> end tell
>
> Before writing the above script, I tried to accomplish the above goal by building an Automator app that included a command that (in turn) included "whose extension is not plist." The resulting app does move extra plist files to the Trash, but it also moves itself to the Trash! I don't understand that behavior!
>
> Thanks in advance,
>
> Barry
Hello Barry,
Perhaps could you have a look at this one:
tell application "System Events"
tell preferences folder of user domain
try
delete (files whose (name begins with "widget-com.apple.widget.weather.plist")) and (name does not end with ".plist")
end try
end tell
end tell
But beware, since the deletion may happen without the trash can safety belt...
That said, currentUser in your script just contains the name of the current user; it's thus a string, not a folder. Hence, you should have something like:
delete (every file of folder "Preferences" of folder "Library" of folder currentUser of folder "Users" whose name contains "widget.weather" and name extension is not "plist")
in your tell block targeted to the Finder.
But this anyway assumes that the user really has his home directory in folder "Users" (whichever it is), and that the Finder's preferences do not interfere with the way file names are displayed.
And I really don't know why such seemingly redundant preference files are stored, nor the way they are supposed to have some use.
HTH,
Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden