Delete files but not folders script

Hi all,

I am looking for a script that can delete only the files and leave the folders and sub-folders on a volume. I know it’s not that hard maybe. I am new to scripting so bear with me. Any help would be appreciated! Will this work?


tell application "Finder" to delete every file of entire contents of disk volume Vol_archive

Worked just fine for me like this:


tell application "Finder" to delete every file of entire contents of (choose folder)

Deleted all the files, but left all folders and sub folders intact.

That works great…:smiley: how would you write it to not stop errors.

How about this:


tell application "Finder"
	try
		delete every file of entire contents of (choose folder)
	end try
end tell

Thanks CAS!

That script saved me 8hr+ of work! At least I was close to the right script.