WATCHFOLDER
han= file.watchfolder(path, cmd, maxwait, keywords)
Monitors activity in the folder given by path: when a change occurs, executes the cmd. If maxwait is specified, it gives the maximum wait time in milliseconds. If it is omitted or 0, there is no maximum. The keywords give a string of blank-separated keywords, eg "subtree size". The allowed keywords are:
subtree - monitor subfolders of path as well
file - monitor for new, deleted or renamed files
folder - monitor for new, deleted or renamed folders
size - monitor for changes in file size
lastwrite- monitor for changes in last write date of file
security - monitor for changes in security settings of file
If keywords is omitted, then "file" is assumed. Each watchfolder activates a new thread, so you can use as many as you want.
The global variable _exit_ is set according to how the folder changed, the global variable _folder_ is set to the folder, and and the global variable _file_ is set to the name of the changed file (omitting the path to the watched folder). The possible values of _exit_ are 0 for unknown, 1 for timeout, 2 for file added, 3 for file deleted, 4 for file attributes changed, 5 for file renamed. For Win 95/98/Me, _file_ is always set to "" and _exit_ to 1 or 0.
For W2K and later, if the cmd ends in a comma then a parenthesis, for example, "myscript(,)", then the folder name and the file name are inserted as the last two arguments. It is recommended that this approach be used if you have multiple outstanding watches, as if more than one watch ends at the same time, it is possible that the global variables will be overwritten.
The returned handle can be used to end the watch with the command
file.endwatchfolder(han)
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1