Search This Blog

Loading...

Tuesday, 31 July 2012

Automatically copy a file to multiple directories

Q&A

Perhaps I should blog a little more often. Perhaps just some questions from customers and answers from me.
Sometimes the answers are so obvious to me, but people who didn't use WatchDirectory as long as I did may find this useful.

How can I copy a file to multiple target directories?

Easy (part 1): just configure multiple Copy Files tasks.

Easy and Obvious. Another question answered. Another happy customer!!

How can I copy a file to multiple target directories in ONE process?

Oops. If you setup multiple tasks like described above, you will have multiple processes running (one for each "target directory"). Not a big problem if you want to copy to 3 or 4 targets but Windows will not like it if you need to copy to (say) 30 or 40 target directories.


Easy Answer - Alternative 1 - Sort Files

As copying files is one of the most popular uses for WatchDirectory (together with email notifications and Upload Files) we made a task especially for this.

It is called the Sort Files plugin. It is one process that monitors a directory and uses "rules" (see here) to determine where it should copy the files to. If you do not set the "final" option for a rule, the rules after it will also run, thereby allowing you to copy a file to multiple locations.


Easy Answer - Alternative 2 - Subtasks

WatchDirectory Professional (not the Standard edition) includes a plugin called the Subtask plugin. This is a more general task that can call other plugins (including "Copy Files", "Upload Files" and "Email Files") for each detected new or changed file.

See Also

How many tasks does WatchDirectory support?


2 comments:

Anonymous said...

On the question: How can I copy a file to multiple target directories?
Easy (part 1): just configure multiple Copy Files tasks.
How do you ensure the source file is not deleted until after the last task copied it to the new folder?

Gert said...

For that you really should use one of the 2 alternatives (subtasks or Sort Files) because with them you have complete control when the file is deleted.