I’m not sure what is the question here, but one thing for sure
tell application "Finder"
is the one that should be used to delete files. At least Finder is always the app I’ve used in the past. I know System Events has two delete commands and this is probably where you’re having a problem in your second script. You need to specify a disk object (alias) most certainly so it is not confused.
But I’d stick with Finder nonetheless…
Browser: Safari 537.78.2
Operating System: Mac OS X (10.8)
Don’t speak to the Finder as long as it’s not absolutely required.
Finder is an old beast which doesn’t evolve seriously with the operating system.
Just an example : Standard Additions and System Events are aware of the property type identifier which is the modern way to identify a type of disk items. The declining Finder don’t know this property.
When we want to delete a single disk item whose pathname is known, System Events does the job correctly.
Here, the problem is that it fails to delete every items of a folder in a single call.
As we saw in an other thread open by BigJack,
delete files of folder myBeautifulFolder
behaves flawlessly to delete flatfiles.
What is puzzling is that it seems that this kind of syntax doesn’t apply to packages or folders which, like flatfiles are disk items.
Given this odd behaviour, if we want to use System Events, we must delete the disk items one by one with :
set userHome to path to home folder as text
-->> "<startup Volume>:Users:<current User>:"
set folderOne to "testQ"
tell application "System Events"
set theItems to every disk item of folder (userHome & "Downloads:" & folderOne) # EDITED
repeat with anItem in theItems
delete disk item (path of anItem)
I continue to think that if we want to really delete items, triggering System Events is better because the Finder just move them to the trash were they remain as long as we don’t empty it.
Yvan KOENIG (VALLAURIS, France) jeudi 25 septembre 2014 15:25:58