Re: Monitor Folder For Changes
Re: Monitor Folder For Changes
- Subject: Re: Monitor Folder For Changes
- From: "Marc S.A. Glasgow" <email@hidden>
- Date: Wed, 18 Dec 2002 22:23:54 -0500
Do a item count of the folder contents first, then execute the copy
operation, then recheck the count. If the count has remained the same,
then there is no need to determine what else to copy; if it has
changed, then you start the compare/copy process again, comparing it to
the previous file list. Note that if you are doing recursive folders
(i.e. - folders within folders within folders) to be monitored, then
you either need to use recursion or use a third-party utility to 'walk
the folders' contents.
set ListOFiles to list folder "hd:foldername:"
set FileCount to count the number of items in ListOFiles
-- do the copy operation(s)
set NewListOFiles to list folder "hd:foldername:"
set NewFileCount to count the number of items in NewListOFiles
If not (FileCount = NewFileCount) then
-- figure out the new additions or trigger flag to start over
else
-- trigger flag to quit
end if
Best Wishes,
=-= Marc Glasgow
I am trying to write a script which will monitor a folder and copy any
files which are newly added or updated to another location. So far, I
have a folder action script which launches when a file is added to the
folder. I check the creation date of files in the folder and copy
recently-created files to another folder.
The problem is this:
the files are very large so they take a minute or two to copy. During
this time, another file or files might be added to the folder, in
which case they are ignored by my script once it is done copying. Is
there some way I can avoid missing any changes to the folder as far as
new/updated files? I'm hoping someone has a ready-made script which
does just this, since it seems like a generally useful tool.
FWW
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.