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?
|