Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Help with Script

Help with Script
Thread Tools
iBookUser
Forum Regular
Join Date: Oct 1999
Location: Everett, WA USA
Status: Offline
Reply With Quote
Jul 2, 2002, 02:02 AM
 
Hi All,
Applescript is probably the one area of the Mac OS that I know next to nothing about. I'm looking for info on where I could find simple instructions or tutorials on how to use it. Lately I've been thinking it would be nice to know how to use. Looks like it can save lots of time.
I would like to write a script that would go through a folder I have chosen, and delete all files with a certain criteria, say all files with "funny" in the name, something like that. Is it possible? Hard? How would I get started? Any suggestions?

Thanks
Matt
     
Synotic
Mac Elite
Join Date: Oct 2000
Status: Offline
Reply With Quote
Jul 2, 2002, 10:47 AM
 
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by iBookUser:
<strong>Hi All,
Applescript is probably the one area of the Mac OS that I know next to nothing about. I'm looking for info on where I could find simple instructions or tutorials on how to use it. Lately I've been thinking it would be nice to know how to use. Looks like it can save lots of time.
I would like to write a script that would go through a folder I have chosen, and delete all files with a certain criteria, say all files with "funny" in the name, something like that. Is it possible? Hard? How would I get started? Any suggestions?

Thanks
Matt</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Why <a href="http://www.apple.com/applescript/" target="_blank">http://www.apple.com/applescript/</a> of course

If you really are committed, you can see if you can get a copy of Danny Goodman's Guide to AppleScript.

Something like that.. I know the name is right.

For your particular question...

deleteAllFunny(choose folder)

on deleteAllFunny(nextFolder)
��try
����tell application "Finder" to copy nextFolder's items to folderList
����
����repeat with newFile in folderList
������copy newFile's file type to tempFileType
������if tempFileType is "fold" then
��������deleteAllFunny(newFile)
������else
��������if newFile's name contains "funny" then
����������tell application "Finder" to delete newFile
��������end if
������end if
����end repeat
��end try
end deleteAllFunny

I used Greg Strange's recursion method and modified it for your use. You can find lots of handlers at <a href="http://www.applemods.com/" target="_blank">http://www.applemods.com/</a> however I wouldn't try actually looking at the code... For some reason it seems like lots of prior coders write all those AppleScripts using methods they learned in computer scienece or whatever. To use that particular script, just paste it into the Script Editor and press run.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 08:41 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,