Move new files to server: Brute force

Since I’m at a loss to figure out why Folder Actions are not working for Distiller moving PDF files, see my earlier script http://bbs.applescript.net/viewtopic.php?id=20591.

So looking around I’m trying to move files from this Out folder to the server by repeating to infinity (as long as the folder exists) for files that are 30 minutes old. But I’m not getting more than errors about latching on to these files. I was hoping to avoid another repeat loop by using “every” and “whose”.

Is there a better way? thanx, sam


property this_folder : "Homer:Users:Shared:acrobs homer:proofs:Out:"
property zacrob : "MrJr:Zacrobs:"

tell application "Finder"
	if folder zacrob as alias exists then
		tell (every file of (this_folder as alias) whose (modification date is greater than (current date) - (30 * 60)))

			move every file to (folder zacrob as alias) replacing yes
		end tell --every file
	end if
end tell --finder

Hi Sam,

try this:

property this_folder : "Homer:Users:Shared:acrobs homer:proofs:Out:"
property zacrob : "MrJr:Zacrobs:"
tell application "Finder"
	try
		move (every file of folder this_folder whose modification date > ((current date) - 30 * minutes)) to (zacrob as alias) replacing yes
	end try
end tell --finder

Note: if zacrob doesn’t exist, an error occurs and will be ignored

Yes, it certainly does and I’m grateful because my efforts hit around the answer.

I guess I want to run this every five mins or so. Would I set up a repeat loop for minutes, or build an iCal event and attach this script?

thanx, sam


-- Save as stay-open application. Quit from dock.

property zacrob : "MrJr:Zacrobs:" as alias
property this_folder : "Homer:Users:Shared:acrobs homer:proofs:Out:" as alias

on idle
	tell application "Finder"
		try
			move (every file of folder this_folder whose modification date > ((current date) - 30 * minutes)) to zacrob replacing yes
		end try
	end tell --finder
	return 300 -- seconds
end idle

This will idle in the background using almost no resources, then run every fifth minute (plus its run time) after it starts.

Thank you both for this script. It works as advertised and opens me up to another bit of code I was unaware. :slight_smile:

On idle scripts are quite reliable, but can occasionally grow if left running for days – check once in a while, or restart occasionally.

StephanK, that worked like a charm for me as well.
:cool:
Thank you!

Model: XServe
AppleScript: 2.3 (118)
Browser: Safari 533.21.1
Operating System: Mac OS X (10.6)