• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to delete extraneous plist files via AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to delete extraneous plist files via AppleScript


  • Subject: Re: How to delete extraneous plist files via AppleScript
  • From: Christopher Stone <email@hidden>
  • Date: Wed, 12 Jan 2011 21:06:46 -0600

On Jan 12, 2011, at 17:36, Axel Luttgens wrote:
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
______________________________________________________________________

Hey Axel,

That's nice.  I'd forgotten that System Events could so roundly whip the Finder with filter forms.  The Finder takes a full 10 seconds to grind out the equivalent on my i7 MacBook Pro.

Barry: here's another alternative.

try
set prefsFolder to quoted form of (POSIX path of (path to preferences folder from user domain))
set shellCMD to "find " & prefsFolder & " -name \"*widget.weather*\" -depth 1 | egrep -iv \".plist$\""
set oldTIDS to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set foundFiles to text items of (do shell script shellCMD)
set AppleScript's text item delimiters to oldTIDS
repeat with ndx from 1 to length of foundFiles
tell foundFiles to set item ndx to POSIX file item ndx as alias
end repeat


foundFiles


# tell application "Finder" to delete foundFiles


on error errMsg number errNum
beep
display dialog "Error: " & errMsg & return & "Error Number: " & errNum
end try

It's not pretty, but it's quick.  It deletes to the Trash, so if you goof you can recover.

Question for the more experienced shell scripters: What is the safest way to pass the find results to 'rm' in a one-liner?

Thanks.

--
Chris
 _______________________________________________
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

  • Follow-Ups:
    • Re: How to delete extraneous plist files via AppleScript
      • From: Axel Luttgens <email@hidden>
References: 
 >How to delete extraneous plist files via AppleScript (From: Barry Fass-Holmes <email@hidden>)
 >Re: How to delete extraneous plist files via AppleScript (From: Axel Luttgens <email@hidden>)

  • Prev by Date: Re: Remote AppleScripting oddness
  • Next by Date: Re: Remote scripting 10.6.x calling 10.5.x
  • Previous by thread: Re: How to delete extraneous plist files via AppleScript
  • Next by thread: Re: How to delete extraneous plist files via AppleScript
  • Index(es):
    • Date
    • Thread