I have a simple folder action that I have been using for over a year. It renames a file and sends it to the containing folder. Now all of a sudden it has started to transport the files to the Trash. It works okay on some folders and not others, and folders it worked on will suddenly go bad also. The script works fine on other machines.
I am thinking it is something wrong with the computer, not the script. I have run Norton and Disk warrior and it still happens. Any advice? Anyone seen this before?
It isn’t likely that a script would break for no reason. Have you recently upgraded anything (Mac OS, AppleScript, etc.). Can you post the script here for inspection?
Here’s the script. Like I said, I am wondering if it’s the machine. Haven’t updated anything significant lately.
on adding folder items to theFolder ¬
after receiving stuff
tell application “Finder”
with timeout of 500 seconds
repeat with aFile in stuff
if the name of aFile contains " copy" then --tests to see if copy is in the name
set x to the name of aFile --gets the name of the file
set y to length of x – gets the number of characters in the name
set newx to (text 1 thru (y - 9) of x) & (text (y - 3) thru -1 of x) --makes a new name subtracting the characters in " copy"
set name of aFile to newx – renames the file
move aFile to (container of theFolder) with replacing --moves renamed file to folder above replacing same named file
end if
end repeat
end timeout
end tell
end adding folder items to
Yep, it sounds more and more like a problem with the machine. Have you rebuilt the desktop lately? On my pre-OS X machine, this is considered a regular monthly task.
You don’t happen to have more than one folder action attached to the troublesome folder(s) do you?
Nope, rebuilding didn’t help. Oddly enough when I make a new set of folders and copy one of the files into its subfolder and run it everything works fine, but when I make a new containing folder named the same as the original and a new subfolder, it doesn’t work. It’s as if the finder doesn’t want to see a containing folder with that name.
I’ll keep plugging away. I’m about to start on a new job with new files so we’ll see how it works with that.
Here’s a thought: is there be some kind of file size limit on folder actions? The folder in question is over a GB even though the files are on the order of 20-30 MB.
I don’t know if there are size limits. Have the file sizes changed/grown since the time when the script worked?
Since the script worked at one time, I would look for things that might have changed (maybe even due to a crash or system freeze). You might consider deleting related preference files to rule out a corrupt file. Sometimes a corrupt setting file can cause all sorts of problems. I’d start with Finder prefs and anything else that might be related to scripting and folder actions. If you don’t want to lose settings, you can move them out of the Preferences folder one at a time to see if it helps and then move them back if it doesn’t. It might require a restart to see the results.
Thanks. Yes, the file sizes grew steadily. I am not sure what they were at the point it stopped behaving but I think it was still working at a pretty large size.
Maybe I’ll trash the prefs though I hate to do it.
Seems to be working fine with the new job. I’ll keep an eye on the sizes and see what happens if it dies again.
Just to follow up, had a crash (server problem) and the scripts crapped out again. Trashed Applescript prefs and that seems to have fixed it. So now I know.