WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> German >> Need of extended Script @ file-copy
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1207057038

Message started by rkelly_2 on Apr 1st, 2008 at 3:37pm

Title: Need of extended Script @ file-copy
Post by rkelly_2 on Apr 1st, 2008 at 3:37pm
Hi Support,

i need the following sequence in the script:

Check folder for new pdf files
Run some other commands to manipulate the actual file
copy it to a new location with a new name with the actual date
run some other commands, like
echo The file %WD_FILE% is in progress... >> c:\temp\logs\wd_protocoll.log

What i´ve done is the following:

Create n new   automatic copy  task
Use dynamic naming for the target fiel:
C:\tmp\Aktuell{year}{monthname}{hour24}_{filetitle}
Remove the file after successfil copy
Only @ pdf files
Fast monitoring method

But i need to run some other cmd commands before/after the copy of the file.
Can i create a wd.bat file in the task directory, in which i can set my commands?

Thanks

André

Title: Re: Need of extended Script @ file-copy
Post by Gert on Apr 2nd, 2008 at 8:25am
Hello André,

The "wd.bat" trick only works for tasks based on the "run a .bat file" plugin. sorry. A future version will allow you to "combine" tasks in a way you describe.

Currently, you would need to do it with a bat script, something like this:
[code]echo The file %WD_FILE% is in progress... >> c:\temp\logs\wd_protocoll.log
rem .. do some commands on the actual "%WD_FILE%"
rem make sure the target directory exists
SET YEAR=%WD_DATE:~0,4%
SET MONTH=%WD_DATE:~4,2%
SET DAY=%WD_DATE:~6,2%
SET HH=%WD_TIME:~0,2%
MD "C:\tmp\Aktuell%YEAR%%MONTH%%DAY%%HH%"
rem copy the file
COPY "%WD_FILE%" "C:\tmp\Aktuell%YEAR%%MONTH%%DAY%%HH%"
if %ERRORLEVEL% EQU 0 (
  DEL "%WD_FILE%"
)
[/code]

Title: Re: Need of extended Script @ file-copy
Post by rkelly_2 on Apr 2nd, 2008 at 9:20am
Hi Gert,

thanks for your response and help.
This solution is OK; I did not know that I can use the variables from WD in my batch file.

Bye

André

Title: Re: Need of extended Script @ file-copy
Post by Gert on Apr 2nd, 2008 at 10:43am
There are a lot more variables you can use, they are described here (English):
http://www.watchdirectory.net/wdhelp/plugins/wdopAutoRunBatEnv.html
and here (German):
http://de.watchdirectory.net/wdhelp/plugins/wdopAutoRunBatEnv_deu.html

By the way, if you want to "sharpen" your batch file skils, I can highly recommend this book:
"Windows NT Shell Scripting"
by Tim Hill
isbn: 1-57870-047-7
http://www.amazon.com/Windows-NT-Shell-Scripting-Circle/dp/1578700477


Gert

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