Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File Trigger Cannot Monitor Files in Subfolders
#1
I need to monitor files inside a folder named T on the desktop.
If I drag and drop a folder named A (which contains a file named A.txt) into the T folder, the trigger does not work. Nothing is displayed in the Output panel, and neither the trigger type nor the file path is reported.
The following video demonstrates the issue.

[Image: demo.gif]
#2
1. QM bug - somehow file triggers don't work when the filename length is < 3.

2. QM triggers use the logic of the used Windows API. When a folder added, we have a notification for that folder only, not for files in it. Workaround: Let the script trigger include all files and folders; then enumerate files.

Function File_trigger_files_in_added_folder
Trigger $f 0xC07 "C:\Test"     Help - how to add the trigger to the macro
Code:
Copy      Help
;\
function event $name [$newname]
;event: 1 added, 2 removed, 4 renamed, 8 modified
out F"{event} {name}"

if event=1 ;;added
,if FileExists(name 2)=2 ;;folder
,,Dir d
,,foreach(d F"{name}\*.txt" FE_Dir 4) ;;enum descendant txt files
,,,str path=d.FullPath
,,,out path
,,
,,
#3
Thanks for your help.
I tested the trigger code above, but it still doesn't work.
#4
The trigger is changed too, not only code.
#5
Thanks for your help. After restarting QM, the settings took effect.
 
Also, I need the trigger to fire only after all files in the target folder have finished copying. Is there a simple way to achieve this?
For example:
I copy a folder named "ABC1" into the folder C:\Test. The "ABC1" folder contains several files, each hundreds of MB in size, so it takes some time for all files to finish copying to the destination folder.
I want the trigger to fire only after all files have been completely copied, and then output the folder path and file paths.
#6
Does the file-trigger script know the path of the copy-source folder? Then we can make the script better. But it can't be used when *moving* instead of *copying*.

In any case can't make this 100% reliable. And the code isn't easy to create. Need to manage multiple "file change" events. Possibly slow.

If possible, instead use a script (eg cmd, PowerShell or QM) that copies files and then launches a QM macro. Then don't need a file trigger + code to wait until all files completely copied.
#7
Sorry, I forgot to mention one detail: in actual use, `C:\Test` is located in a shared folder, and the `ABC1` folder is copied into that shared folder from another computer.
#8
Can't know when the copying operation ended.

Maybe after copying files the remote computer can execute a process (start a QM macro) on the shared computer? Eg using PsExec or WMI or PowerShell or schtasks. Then would not need file triggers. Or after copying make an extra filesystem change (create/delete/rename/attributes/etc) and use it for the file trigger.


Forum Jump:


Users browsing this thread: 1 Guest(s)