applescript timer

this script moves all files (not folders) to the current temp folder.
Although it’s allowed I recommend to avoid slashes in file and folder names.
As the desktop folder of the current user is the “root” folder of the Finder, the folder specifications are quite easy


set dateStamp to do shell script "date '+%Y_%m_%d'"
set todaysFolderName to "Collection " & dateStamp
tell application "Finder"
	if not (exists folder "temp") then make new folder with properties {name:"temp"}
	repeat
		set filesToMove to files of desktop
		if (count filesToMove) > 0 then
			if not (exists folder todaysFolderName of folder "temp") then
				make new folder at folder "temp" with properties {name:todaysFolderName}
			end if
			--find the generic folder
			move filesToMove to folder todaysFolderName of folder "temp"
		end if
		delay 60 * 30
	end repeat
end tell

That’s what I thought all along…
Next time, answer the questions, and you save yourself, and us, a lot of wandering about.

A folder action can NOT do that. It will be triggered when something appears in its folder, and act on what was dropped, and nothing more.
It will not sit and wait if anything else is dropped, and then act on that as well.

Stefan said:

and that does what you want.
In the mean time you could run the script (without the ‘on adding’ handler) as a plain script from the Script Menu.
Or save it as application, and drag to the Finder toolbar, to click whenever you want to clean up.

To find out about stay-open scripts go to the Unscripted section of MacScripter.
Searching for ‘launchd’ will turn up loads of stuff.
The AppleScript Language Guide is here.

Edit:

Ah. Stefan gave you a script while I was writing this. And I learned something from his code - yet again.

i apologise for my stupidity but like i said this was a way for me to learn and that is what i did thanks for all your help people i learnt a lot in just a few days