WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> Plugins >> Move file after rename
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1461716642

Message started by ChanceBuckman on Apr 27th, 2016 at 2:24am

Title: Move file after rename
Post by ChanceBuckman on Apr 27th, 2016 at 2:24am
Need solution to move renamed files to archive folder. 

Task to copy monitored folders files to target folder complete (1-3):
1.      Network folder (and subfolders) being monitored for changes:  \\server1\_products
2.      Network folder events in monitored folder are synced to \\server1\product-docs
a.      Only extensions copied are PDF & DWF
3.      If file already exists in \\server1\product-docs it will be renamed (using program default for file rename)
[filename.][year|month|date|hr|min|sec.][extension]

Need task to complete following:
1.      After the existing file is renamed, it should move to folder \\server1\archive (keeping same file structure as \\server1\product-docs) the same should happen as other files are copied to the target folder.
2.      In short, the latest update of the file would be located in \\server1\product-docs, all versions of the renamed files would remain in \\server1\archive
3.      It’s not necessary to use the default program way to rename the existing file, could be file1.pdf, file2.pdf, etc.

Thank you in advance

Title: Re: Move file after rename
Post by Gert on Apr 27th, 2016 at 9:30am
It sounds that it all can be done by one task using the "Sort Files" plugin - http://www.watchdirectory.net/wdhelp/plugins/wdopAutoSort.html

Sort Files allows you to create 1 or more "Rules" and each rule can copy the detected file to a different location.
The target of each copy uses {Dynamic Naming} ( http://www.watchdirectory.net/wdhelp/plugins/dynamicname_functions.html ) so you can add your timestamps etc.

Let's see...
Rule 1: CopyToProductDocs
set the "match" field to * so it matches all files
do not set the option "This is a final rule" (you want the next rule to run as well)
copy detected file to
\\server1\product-docs\{relativedir}\{filetitle}_{year}{month}{day}_{hour24}{min}{sec}.{extension}

Rule 2: MoveToArchive
set the "match" field to * so it matches all files
copy to  \\server1\archive\{relativedir}\{filename}
Set the option "This is a final rule" and its suboption "Delete the original after copy"

In the task settings for "filter events" you can make sure the task only detects PDF and DWF files.

As you are monitoring/copying on a network drive, make sure to read this blog:
http://blog-en.gdpsoftware.com/2010/04/watchdirectory-tasks-as-windows-service.html


Title: Re: Move file after rename
Post by ChanceBuckman on Apr 27th, 2016 at 8:54pm
Thanks for the swift reply.  This does everything I needed, but I forgot to include an important process in my original post.  If a file is deleted from the monitored folder (_products), it also needs to be deleted from the target (product-docs).  In the config file, I changed "evtFileDel=0" to "evtFileDel=1" Get error in history:  ;task settings have FILEDEL set, but plugin does not support FILEDEL. Setting ignored.;;, is this possible to do?

Title: Re: Move file after rename
Post by Gert on Apr 28th, 2016 at 6:59am
That sounds like a bad idea....

Your specification (first post) says your task MOVES the file from _products to archive, which effectively is a "delete". So what you are saying now if that after the file is processed (copied to product-docs and moved to archive) the file must be deleted product-docs again. So basically, the file will be present in product-docs for only a few milliseconds.....

Title: Re: Move file after rename
Post by ChanceBuckman on May 4th, 2016 at 10:41pm
Turns out we don't need to do that anyway, and I missed a bit of information, otherwise I think this will work.  Rule 1-If the file already exists in the destination, it should be renamed, then moved to archive.  E.G. if the file BOB.PDF already exists in ProductDocs, it would  be renamed BOB.OLD, then moved to Archive, in short, ProductDocs always has the recent file (BOB.PDF), Archive would have all the files to keep track of changes (BOB.OLD1, BOB.OLD2, etc.)  extension is not important, could be .rev1, .rev2, etc.

Sorry to be a pain, thank you in advance.

Rule 1: CopyToProductDocs
set the "match" field to * so it matches all files
do not set the option "This is a final rule" (you want the next rule to run as well)
copy detected file to
\\server1\product-docs\{relativedir}\{filetitle}_{year}{month}{day}_{hour24}{min
}{sec}.{extension}

Rule 2: MoveToArchive
set the "match" field to * so it matches all files
copy to  \\server1\archive\{relativedir}\{filename}
Set the option "This is a final rule" and its suboption "Delete the original after copy"

In the task settings for "filter events" you can make sure the task only detects PDF and DWF files.

WatchDirectory Forum » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2017. All Rights Reserved.