Delete contents of folder? Still a noob =/

I have a current script to create a folder if it doesn’t already exist.
I need to add a line to delete any files in said folder as well (if any already exist).

I have tried a couple times with examples from here and elsewhere, and I just keep screwing up the script completely, or having no change at all. Help please?

-- Create a hidden folder on the desktop.  If it already exists, delete current contents.
set theOutputFolderPath to path to desktop folder
set theNewFolderName to ".hidden"

tell application "Finder"
	if (exists folder (theOutputFolderPath & theNewFolderName as string)) = false then
		make new folder at desktop with properties {name:theNewFolderName}
	end if
end tell

Maybe something like this…

set theOutputFolderPath to path to desktop folder
set theNewFolderName to ".hidden"

tell application "Finder"
	if (exists folder (theOutputFolderPath & theNewFolderName as string)) = false then
		try
			make new folder at desktop with properties {name:theNewFolderName}
		end try
	end if
end tell

do shell script "rm -fr ~/Desktop/.hidden/*"

Tom

Thanks Tom. Seems to work great. Please see last post over here on it:
http://macscripter.net/viewtopic.php?pid=147558

Correction. This doesn’t seem to work on invisible folders (folder names starting with “.”, for example “.hidden”)

This will delete the .hidden folder on your desktop…

do shell script "rm -fr ~/Desktop/.hidden/"

Tom

That’s an idea. The following seems to work with visible AND invisible “.”. I believe this step is solved. relevant portion (from larger script) shown below:

do shell script "rm -fr ~/Desktop/.hidden/"

set theOutputFolderPath to path to desktop folder
set theNewFolderName to ".hidden"

tell application "Finder"
	if (exists folder (theOutputFolderPath & theNewFolderName as string)) = false then
		make new folder at desktop with properties {name:theNewFolderName}
	end if
end tell