WatchDirectory home page
WatchDirectory Startseite (Deutsche Version)
Site WatchDirectory (Français)
  Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
   
  HomeHelpSearchLoginRegister  
 
Page Index Toggle Pages: 1
how to run a .bat file when... (Read 2472 times)
troynall
YaBB Newbies
*
Offline



Posts: 2
how to run a .bat file when...
May 25th, 2011 at 7:39pm
 
I have a network drive called Z:
Folder Z:\data already exists.

A folder will get created called Z:\data\003456
The folder name is comprised of numbers only
and will be unique in nature(never repeating)

Inside of that folder "003456", is a corresponding file named 003456.oxi

I need to run a batch file(located on the desktop) called process.bat

After completion of the above process.bat file,

I need to verify that a file called "003456.pdf" was created in the folder called Z:\pdf\003456
the above bat file(process.bat) will create this folder(Z:\pdf\003456).

and then move(not copy) the FOLDER(and corresponding oxi file) Z:\data\003456\003456.oxi to c:\archive

I realise that this might be several watchdirectory jobs.

So maybe someone could steer me in the right direction ?
I have tried to setup a run bat file sequence, but cant get it to work.


Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2239
The Netherlands
Re: how to run a .bat file when...
Reply #1 - May 25th, 2011 at 9:47pm
 
Hello Troy,

[quote]network drive called Z:[/quote]
[quote]run a batch file(located on the desktop)[/quote]

"The Desktop" and "mapped network drives" will not work if you run the WatchDirectory task as a Windows Service, please see
http://blog-en.gdpsoftware.com/2010/04/watchdirectory-tasks-as-windows-service.html

If you run the task "normally" (or make the changes as described in the blogpost), something like this would work. Also see the following link for a description of %WD_xxxxx% environment variables: http://www.watchdirectory.net/wdhelp/plugins/wdopAutoRunBatEnv.html

untested code below, use as a sample to get you started. Configure WD to run the task for new files (FILENEW) and only for  files with a .oxi extension (see http://www.watchdirectory.net/wdhelp/help/filter_events.html )
[code]
rem check if we are called for an oxi file
IF "%WD_FILE_E%" NEQ "OXI" GOTO :EOF
rem check if we are called for a FILENEW event
IF "%WD_REASON%" NEQ "FILENEW" GOTO :EOF

rem call the bat script
rem the script can use %WD_FILE% (and probably %WD_FILE_D%) to know what to process
CALL "C:\Scripts\Process.bat"

rem check if the pdf exists....
IF NOT EXIST "Z:\Pdf\%WD_FILE_B%\%WD_FILE_B%.pdf" GOTO :PDFDoesNotExist

rem move the directory to C:\backup
MOVE "Z:\data\%WD_RELDIR%" "C:\Backup"
rem done
GOTO :EOF

:PDFDoesNotExist
rem perhaps send an email? see http://www.watchdirectory.net/wdhelp/plugins/wdopAutoRunBatEmail.html
[/code]
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
troynall
YaBB Newbies
*
Offline



Posts: 2
Re: how to run a .bat file when...
Reply #2 - Jun 16th, 2011 at 10:44pm
 
this worked !!!

Thank you very much. Smiley
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1