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 > Need some Applescript Help

Need some Applescript Help
Thread Tools
Addicted to MacNN
Join Date: Oct 1999
Location: The Tollbooth Capital of the US
Status: Offline
Reply With Quote
Jul 30, 2004, 03:33 PM
 
I'm not sure how to move a specific folder or items in a specific folder to the trash using applescript.
"Evil is Powerless If the Good are Unafraid." -Ronald Reagan

Apple and Intel, the dawning of a NEW era.
     
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Jul 30, 2004, 09:30 PM
 
This will move items in a selected folder to the Trash (delete), then empty the Trash.
Code:
tell application "Finder" activate set theItems to selection if theItems is {} then set theItems to {target of front window} repeat with theItem in theItems if class of theItem is folder then delete every item in theItem end repeat empty trash end tell
HTH
Craig
     
typoon  (op)
Addicted to MacNN
Join Date: Oct 1999
Location: The Tollbooth Capital of the US
Status: Offline
Reply With Quote
Aug 1, 2004, 08:54 AM
 
Originally posted by suthercd:
This will move items in a selected folder to the Trash (delete), then empty the Trash.
Code:
tell application "Finder" activate set theItems to selection if theItems is {} then set theItems to {target of front window} repeat with theItem in theItems if class of theItem is folder then delete every item in theItem end repeat empty trash end tell
HTH
Craig
Great thanks. Question. So all I need to do is put the selected folder I want moved and deleted in the {}?
"Evil is Powerless If the Good are Unafraid." -Ronald Reagan

Apple and Intel, the dawning of a NEW era.
     
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Aug 5, 2004, 11:57 PM
 
The first script assumes you have a folder selected before running the script. To have another way to select the folder targeted, you could modify the first four lines so you are presented with a Navigation Window from which you can slect the folder on which you want to act. Here it is:
Code:
set theFolder to choose folder as alias tell application "Finder" activate set theItems to theFolder repeat with theItem in theItems if class of theItem is folder then delete every item in theItem end repeat empty trash end tell
C-
     
   
Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:06 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2