WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> Plugins >> Copy with backup
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1268386453

Message started by andersv on Mar 12th, 2010 at 10:34am

Title: Copy with backup
Post by andersv on Mar 12th, 2010 at 10:34am
Hi,

Im trying to configure a kind of advanced copy script;  my issue is this:

Input folder:   \changedjpg\<file.jpg>

Output folder: \images\<year>\<month>\<day>\<file.jpg>

Where year, month, day is always todays date, so if i put an image named file.jpg in \changedjpg today i want it to be copied to \images\10\03\12\file.jpg.

So far so good, i managed to get it working with dynamic naming, but since this is a production environment i want to make a backup before overwriting the image, i cant find a way to make it combined with dynamic naming.

it would be nice to copy the file only if destination exists, but thats not crucial.

Im also looking for a more advanced copy function, that searches a couple of subdirectories and copies the file to the directory where the file already exists, for example:

\images\sport\10\03\12\sun.jpg
\images\news\10\03\10\dance.jpg
\images\news\10\03\12\dance.jpg
\images\news\10\03\12\flower.jpg

if i put a image in \changedjpg named dance.jpg the script would replace the file \images\news\10\03\12\dance.jpg, but not \images\news\10\03\10\dance.jpg

Could this be done with watchDirectory?



Title: Re: Copy with backup
Post by Gert on Mar 12th, 2010 at 10:42am
If you want to copy a file to multiple destinations (your "backup"), you have 2 options you can use with WD.

1. Use "Sort Files" instead of "Copy"
See http://www.watchdirectory.net/wdhelp/plugins/wdopAutoSort.html
If you set "Final Rule"  to No, one detected file can trigger multiple copy's.

2. Use the "Run SubTasks" plugin
See http://www.watchdirectory.net/wdhelp/plugins/wdopMultiPlugin.html
You can import your current "copy" task so it will become a sub-task.
Then create another SubTask (maybe by importing the "copy" again) for the backup location


If you use
D:\images\news\{year}\{month}\{day}\{filename}
as the dynamic name, your dance.jpg will always be copied to the correct "news" sub-directory, based on today's date.

Gert

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