Go Back   The macosxhints Forums > OS X Help Requests > AppleScript



Reply
 
Thread Tools Rate Thread Display Modes
Old 04-11-2012, 10:35 AM   #1
Chuma
Triple-A Player
 
Join Date: Apr 2008
Posts: 74
Folder action sometimes works

I've made a little folder action script, which takes a received file and puts it in a subfolder representing the current month. It usually works, although the time it takes to react varies from virtually instant to upwards of ten seconds, but sometimes it doesn't work at all. Particularly when I drop several items at once, it might only move some of them. It doesn't seem to depend on the files - the same files might work or not work.

Is this a common problem somehow? Could I improve my script to prevent it?

I'm using OS 10.7.3, but I've experienced it with similar scripts on previous versions too (10.4, I think). Script follows:

Code:
on adding folder items to this_folder after receiving these_items
	tell application "Finder"
		set themonth to ((month of (current date)) * 1)
		set themonth to text -2 thru -1 of ("00" & themonth)
		set thename to "" & (year of (current date)) & "-" & themonth
		if not (exists folder thename of this_folder) then
			make new folder at this_folder with properties {name:thename}
		end if
		set thetarget to folder thename of this_folder
		move these_items to thetarget
	end tell
end adding folder items to
Chuma is offline   Reply With Quote
Old 04-15-2012, 10:32 PM   #2
sojourner
Major Leaguer
 
Join Date: Apr 2010
Posts: 371
Not to dissuade you, but I have never had success with folder actions working consistently. It's on one of the reasons I love, use, and tout Hazel.
__________________
see a problem; solve a problem.
sojourner is offline   Reply With Quote
Old 04-16-2012, 03:11 AM   #3
benwiggy
League Commissioner
 
Join Date: Aug 2006
Location: London
Posts: 5,708
There have been posts here before about editing the launchd script that FolderAction uses to adjust the "respawn throttle" down from 10 to 2 seconds.

I can't remember the exact details, but I did it ages ago and it did improve things, though I do still find that Folder Actions occasionally doesn't wake. But it's much better than it was.
benwiggy is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 02:36 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.