Folder Action Dispatcher Running at 99% Processes

basically something like this.

property targetFolder : (path to home folder) & "Downloads" as string

on adding folder items to this_folder after receiving added_items
	set theFiles to list folder (this_folder as string)
	set iconFile to missing value
	repeat with aFile in theFiles
		if aFile does not start with "-" or aFile does not end with ".icns" then
			do shell script "mv " & quoted form of POSIX path of (this_folder & aFile as string) & " " & quoted form of POSIX path of targetFolder
			set iconFile to this_folder & aFile as string
		end if
	end repeat
	if iconFile is not missing value then
		do shell script "cp -f " & quoted form of POSIX path of (this_folder & aFile as string) & " " & quoted form of POSIX path of targetFolder
	end if
end adding folder items to

Do i have to manually copy the .icns file to another folder…it doesn’t seem to work but i think it can.

It has to be in the source folder. All files are moved except for you icns file, this one will be copied so there is an icns for every run available.

i’m not sure if its me but i applied the folder action to the downloads folder. it doesn’t seem to work

Apply the folder action not to OS X’s default download folder because it will also make an infinite loop.

ok…I’m a little confused. I apply it to /Downloads or to the temp folder were my old script moved the icns file to.

You create an invisible folder, There you will apply this action to, also the download of a file from your browser will put in here as well. Then when a file is downloaded you’ll copy the file to your old folder.

But im not able to sort the stack by date added when i use this script…and folder action dispatcher still starts to run at 99% processes.

Yes you are, probably your source and target folder are the same. This will result in the same error over and over again like in your first post. You just can’t move a file back in the same sction folder where it came from. It’s like said before, your script will end up in an endless loop. I’ve tested this script, just like my previous suggestion, and worked perfectly like you asked for. What you are trying to do is from a conceptual point of view like this (I’ll hope this clear things out)

--this script will result in a stack overflow
moveFile() --the problem starts here

on dispatcherBeginInvoke()
end dispatcherBeginInvoke

on callFolderActionScript()
end callFolderActionScript

on moveFile()
end moveFile

Ok, i created a invisible folder in side the downloads folder “invis_Downloads”. I applied the Folder action to the Invisible folder. when i download files to the regular download folder, nothing happens. when i download files to the invisible folder, the file move to the original folder…did i do it correctly.

Didn’t test it in that way, I had the invisible folder outside the visible folder. but yes you have to download to the invisible folder then your files will be moved to the visible folder and your dock will be (when sort by added) working like expected and no more folder action dispatcher on 99%. At least not on my machine and worked like a charm.

the files just cover up my stack icon when i use that script…it should look like this when the files get downloaded to the stack folder…

anyone got any other suggestions…

what do you do with the icns file? just look at that piece of code an modify it yourself also the invisible folder needs the icns file and not in the download folder.

the .icns file sit in the stack to make it look like there is stuff inside a shoe box. so i need the icns file to stay in the front of the stack.