Property, in On adding handler?

I have a script that needs to keep count of how many times it has been run, so that it can copy stuff to one of four folders.
The property is a counter, going from 1 to 4, and is used to select one of four folders.
I am running OS 10.3 but I’m sure I had something similar running under OS 10.2

example:
property fileCount : 1
on adding folder items to theFolder after receiving theStuff
tell application “Finder”
display dialog fileCount
end tell
if fileCount < 5 then
set fileCount to (fileCount + 1)
else
set fileCount to 1
end if
end adding folder items to

The dialog always reads 1.
Can anyone help please. :?

If this handler is running like an application and when a file is added it runs and then quits, you lose the contents of the variable “fileCount”. “fileCount” only exists in memory and is lost when the application quits. You then have two options. You can return “fileCount” to the calling application or you can write it out to disk somewhere.

Thanks for that Justin. I will try both options to see which suits best. :slight_smile: