• 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: Deleting Folder Contents
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Deleting Folder Contents


  • Subject: Re: Deleting Folder Contents
  • From: Luther Fuller <email@hidden>
  • Date: Mon, 11 Oct 2010 13:24:12 -0500

On Oct 11, 2010, at 12:43 PM, Christopher Stone wrote:

On Oct 11, 2010, at 11:39, Luther Fuller wrote:
I would like to use the following to avoid the files appearing in the trash ...
tell application "System Events" to delete every item of disk item (folderAlias as text)

but, I can't get the last line of this code to work.
______________________________________________________________________

Both of these path specifiers work for me on Snow Leopard:

# set f to "/Users/chris/Downloads/junkystuff/"
set f to "Thor:Users:chris:Downloads:junkystuff:"

tell application "System Events"
delete folder f
end tell

And you can also use the shell of course:

do shell script "rm -dfr /Users/SomeUser/Downloads/junkystuff/"

If you're wanting to retain the folder then just recreate it as part of your script.

Using your suggestion, I modified my code to delete the folder, then make a new folder.
Like this ...

if (exists folder currentUserName of userSpoolFolder) then
(folder currentUserName of userSpoolFolder) as alias
tell application "System Events" to delete disk item (the result as text)
end if
try
make new folder at userSpoolFolder with properties {name:currentUserName}
on error errText number errNr
"Error = " & errNr & return & errText
display dialog the result --**********************
end try
set userSpoolFolder to (folder currentUserName of userSpoolFolder) as alias

Something very strange happens. The folder is deleted without error, but then the
line 'make new folder ...' throws the error: "You don't have permission to create a folder here."
BUT, THEN a new folder is created and the script continues correctly, that is, the last line does
not error.

This code works correctly ...

set userSpoolFolder to (((path to startup disk) as text) & "private:var:spool:cups-pdf:") as alias
tell application "Finder"
if (exists folder currentUserName of userSpoolFolder) then
(folder currentUserName of userSpoolFolder) as alias
tell application "System Events" to delete disk item (the result as text)
end if
set userSpoolFolder to (folder currentUserName of userSpoolFolder) as alias
end tell

But, I am still worried about the missing 'make new folder ...'. Any explanations?

 _______________________________________________
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: Deleting Folder Contents
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Deleting Folder Contents (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: Deleting Folder Contents
  • Next by Date: Re: Deleting Folder Contents
  • Previous by thread: Re: Deleting Folder Contents
  • Next by thread: Re: Deleting Folder Contents
  • Index(es):
    • Date
    • Thread