• 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: Simply deleting a fil
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simply deleting a fil


  • Subject: Re: Simply deleting a fil
  • From: Tim Mansour <email@hidden>
  • Date: Fri, 17 Apr 2009 20:48:31 +1000

2009/4/17 Sutapalli Satyanarayana <email@hidden>:
> Can we add some check like "if __MACOSX exists then delete" and combine with
> this statement.

You can use something like this:

tell application "Finder"
	set file_path to ((path to documents folder as text) & "__MACOSX")
	if exists folder file_path then delete folder file_path
end tell

Or you could use a "try" statement to trap any error:

tell application "Finder"
try
	delete folder ((path to documents folder as text) & "__MACOSX")
on error
	-- do something else if required
end try
end tell

Also, as Yvan has kindly pointed out ... using the Finder "delete"
command places the item in the Trash. If you want to delete without
using the Trash you can tell "System Events" instead. Or you could use
the shell "rm" command as suggested by Skeeve.

--
Tim Mansour
 _______________________________________________
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: Simply deleting a fil
      • From: Emmanuel Levy <email@hidden>
References: 
 >Re: Photomerge (From: Stan Cleveland <email@hidden>)
 >Simply deleting a fil (From: Satyam Satyanarayana <email@hidden>)
 >Re: Simply deleting a fil (From: Yvan KOENIG <email@hidden>)
 >Re: Simply deleting a fil (From: Tim Mansour <email@hidden>)
 >Re: Simply deleting a fil (From: "Sutapalli Satyanarayana" <email@hidden>)

  • Prev by Date: Re: Simply deleting a fil
  • Next by Date: Re: Simply deleting a fil
  • Previous by thread: Re: Simply deleting a fil
  • Next by thread: Re: Simply deleting a fil
  • Index(es):
    • Date
    • Thread