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
batch/filter script (Read 1733 times)
jmendoza
YaBB Newbies
*
Offline



Posts: 4
batch/filter script
Mar 11th, 2014 at 11:56pm
 
I was trying to put a filter script in the copy files plug in based on file name having the MMDD in the first 4 digits of the filename and it is not working. Please help! Thank you.

Here is what i have on the .bat file:
@echo off
SET MMDD=%WD_DATE:~-4%
SET FILENAME=%WD_FILE_N:~,4%

IF %MMDD% EQU %FILENAME% GOTO :SayYes
GOTO :SayNo

:SayYes
ECHO Y > "%WD_FILTERRESULT%"
GOTO :EOF

:SayNo
ECHO N > "%WD_FILTERRESULT%"
GOTO :EOF



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



Posts: 2238
The Netherlands
Re: batch/filter script
Reply #1 - Mar 12th, 2014 at 8:14am
 
Is that the EXACT script you use? Because I see a syntax error here:
Code:
SET FILENAME=%WD_FILE_N:~,4% 


(something missing before the comma).

I am not sure what you try to achieve with this line of code, but if you want to get the first 4 chars of the filename, use
Code:
SET FILENAME=%WD_FILE_N:~0,4% 


The last 4 chars, use
Code:
SET FILENAME=%WD_FILE_N:~-4% 


Everything except the first char, use
Code:
SET FILENAME=%WD_FILE_N:~1% 


Everything except the last char, use
Code:
SET FILENAME=%WD_FILE_N:~,-1% 



If you want to debug your filter script, create a NEW filter script like below:
Code:
rem the file to write all output to, WD_CUREVT contains a unique number for the event
rem so the output file will be something like C:\temp\WDLOG_3124.txt
SET DEBUGOUTPUT=C:\temp\WDLOG_%WD_CUREVT%.txt

rem the batch file to call (bat or cmd)
SET SCRIPTTOCALL=C:\Program Files (x86)\WatchDirectory\Resolvers\MyFilterScript.bat

rem output all variables to DEBUGOUTPUT
ECHO ----- start environment listing ----- >> "%DEBUGOUTPUT%"
SET WD_ >> "%DEBUGOUTPUT%"
ECHO ----- end environment listing ----- >> "%DEBUGOUTPUT%"

ECHO ----- start output of script %SCRIPTTOCALL% ----- >> "%DEBUGOUTPUT%"

rem call the batch script, redirecting all output to DEBUGOUTPUT
Call "%SCRIPTTOCALL%" >> "%DEBUGOUTPUT%" 2>&1

ECHO ----- end output of script %SCRIPTTOCALL% ----- >> "%DEBUGOUTPUT%"
 


and inspect the txt file it creates to see if any problems occur.
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
 
Page Index Toggle Pages: 1