Thanks for the heads up Stefan.
I was just think about something. What if i add a force Quit Script to the end on my original Script. That way if the CPU Processes get to high, Folder Action Dispatcher will be quit and reopen automatically…
on adding folder items to this_folder after receiving added_items
tell application "Finder"
set file_list to name of every file of this_folder
repeat with this_item in file_list
if this_item begins with "-" and this_item ends with ".icns" then
set icon_name to this_item
exit repeat
end if
end repeat
do shell script "mv -f " & quoted form of (POSIX path of this_folder & icon_name) & " /tmp"
do shell script "mv -f " & quoted form of ("/tmp/" & icon_name) & " " & quoted form of (POSIX path of this_folder)
end tell
end adding folder items to
Like Nigel said, your script has an infinite loop. Don’t try to ignore that, solve that problem first.
I thought he said he may have been wrong. How do i solve that problem. The touch command works, but i have to kill the dock to get it to display properly.
Is killing the dock a problem for you? if it’s a visible dock I agree with you that it doesn’t look pretty.
another approach so it looks and feels the same is downloading the files to an invisible folder for example a .download. then you set the folder action to that invisible folder. When a file is added to that invisible folder it you’ll move the files from the the invisible download folder to the visible download folder. Keep a copy of your icon in the invisible folder and at last copy (not move) the icon to the visible folder so it will be added at last and will be visible. The dock will be automatically updated so you don’t need a quit of the dock.
that sounds like it will work.:D…But how would i script that. Its a little out of my league.
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
else
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()
callFolderActionScript()
end dispatcherBeginInvoke
on callFolderActionScript()
moveFile()
end callFolderActionScript
on moveFile()
dispatcherBeginInvoke()
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.