WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> Plugins >> batch/filter script
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1394574964

Message started by jmendoza on Mar 11th, 2014 at 11:56pm

Title: batch/filter script
Post by jmendoza on 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




Title: Re: batch/filter script
Post by Gert on 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%[/code):
(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%[/code):
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%[/code):
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.

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