Folder actions in 10.4.11 won't work.

I am working on a PowerPC G5 Mac running 10.4.11, Script Editor v. 2.1.1(81), and Applescript 1.10.7.

I have written a script and have it in both HD/Library/Scripts/Folder Actions and in HD/Users/Steve/Library/Scripts/Folder Actions. I have attached the script to a folder at Hd/Library/FileMaker Server/Data/Backups/ and have confirmed that the folder actions are enabled. I have run software update and restarted the machine multiple times. My script runs perfectly if I manually run it, but does nothing if left to it’s own attached to the folder.

Here are my 2 questions:
Will scripts attached to folders inside of the Library run automatically?

I was under the impression that simply by attaching the script to the folder the script will execute if there is a change to the folder. Is this true or do I need to write some line in the script to tell it that when a file is added to the folder run this script?

Any help would be greatly appreciated, as this is my first time trying to script a folder.

Thank you.
Steve Balschi

Model: PowerPC G5
AppleScript: 1.10.7
Browser: Firefox
Operating System: Mac OS X (10.4)

Hey Steve:
Folder Actions can be flaky but under ordinary circumstances they’re good enough. Post the script you’re attaching and maybe one of us will spot a flaw.

Jim Neumann

Here you go.

tell application "Finder"
	set CurntDate to the current date
	set BUFolder to "FilemakerBU_" & date string of (CurntDate)
	set FMB to "smb://Name:password@network/FILEMAKERBACKUP"
	--Checks to see if the folder already exists on the desktop
	if not (the folder BUFolder of desktop exists) then
		--Makes a new folder on the desktop
		make new folder with properties {name:BUFolder}
	end if
	--copies the file "PCG_Database.fp7" into the new desktop folder
	copy file "Macintosh HD:Library:FileMaker Server:Data:Backups:PCG_Database.fp7" to folder BUFolder
	--Checks to see if "FILEMAKERBACKUP" is mounted on desktop
	if not (the disk "FILEMAKERBACKUP" of desktop exists) then
		--If "FILEMAKERBACKUP" isn't mounted then it mounts it.
		mount volume "smb://name:password@network/FILEMAKERBACKUP"
	end if
	--Checks to see if it already exists and then moves the new folder with the BU file to "FILEMAKERBACKUP"
	if not (the folder BUFolder of the disk "FILEMAKERBACKUP" exists) then
		move folder BUFolder to folder "FILEMAKERBACKUP"
	end if
	--Deletes the new desktop folder after moving
	delete folder BUFolder
	--Deltes the backup file
	delete file "Macintosh HD:Library:FileMaker Server:Data:Backups:PCG_Database.fp7"
end tell

Hi, Steve.

  1. Put the script in HD/Users/Steve/Library/Scripts/Folder Action Scripts/. If that folder doesn’t exist, it’s OK to create it yourself. The folders where you currently have it are for scripts that enable or disable Folder Actions or attach or detach the Folder Action scripts to or from folders.

  2. The code of a Folder Action script should be in a special, Folder Action handler that reacts to the particular action that you want to trigger the script. If it’s to be triggered by the addition of items to the folder, then it’s:

on adding folder items to thisFolder after receiving addedItems
	-- Your code here.

end adding folder items to

The system supplies the variable thisFolder (or whatever you choose to call it) with an alias to the folder itself and supplies the variable addedItems (or whatever you choose to call it) with a list of alias(es) to the item(s) whose arrival triggered the action.

You should be able to find details of the other kinds of Folder Action handler by typing “Folder Actions” into the search field in Script Editor’s Help.

Thank you Nigel, that was exactly what the problem was.
I appreciate your time.