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
Calling all Cli Gurus (Read 4175 times)
RJG
YaBB Newbies
*
Offline



Posts: 15
Calling all Cli Gurus
Mar 20th, 2011 at 11:05pm
 
I have a problem, that I can't seem to puzzle out..

Enviroment:
 Windows Command Line Batch Process

Back Ground:
My WMC7 HTPC records shows to a folder, from there I have WatchDirectory trigger a batch file for show processing. The batch file logic looks in a SHOWPARMS.txt text file for the show name, and returns to the batch file it’s processing parameters. I have the basic framework up and running.

Inside SHOWPARMS.txt Example:
Glenn;True;"";"C:\VideoCaptures\GlennBeck";False;"";False;False

Returns:
True;"";"C:\VideoCaptures\GlennBeck";False;"";False;False

Batch File Commands So Far:
set SEARCHNAME=%WD_FILE_B:~0,4% :find from left to right the row that matches the first 4 characters

:: Get the Show Params
for /f "tokens=2-9 delims=;" %%A in ('findstr /b /i "%SEARCHNAME%" "C:\SyncFiles\Bat Files\SHOWPARMS.txt"') do (

set sQSF=%%A
set sCOM=%%B
set sPAT=%%C
set sRAR=%%D
set sUPL=%%E
set sSFV=%%F
set sDEL=%%G

)

Problem:
I need to parse the string backwards from the first "-" (I think). So if a show name is less the 4 characters the batch would still find it in the text file.

So code would not only find this string using "Glen" or "Glenn" In "Glenn Beck-" or "GlennBeck-" (Which currently works) but would also need to find "V" in "V-" (currently the show would be missed due to the < 4 characters show name.)

Then "-" after the show name is always there.


Objective:
 To make the search string length variable (I think), and not based on the current limited 4 character requirement. To find the "-" after the show name and match as many characters as possible. (I think). Wink


Any ideas how I can pull this off?

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



Posts: 2239
The Netherlands
Re: Calling all Cli Gurus
Reply #1 - Mar 21st, 2011 at 6:25am
 
This script is an example to get everything from WD_FILE_B before the first dash. This example's output:
Code:
"Hello World-bla" results in "Hello World"
"GlennBeck" results in "GlennBeck"
"V-nlndslgnnglgsd" results in "V"
 



The script:
Code:
@echo off
SET WD_FILE_B=Hello World-bla
Call :GetUntilDash
ECHO "%WD_FILE_B%" results in "%SEARCHNAME%"

SET WD_FILE_B=GlennBeck
Call :GetUntilDash
ECHO "%WD_FILE_B%" results in "%SEARCHNAME%"


SET WD_FILE_B=V-nlndslgnnglgsd
Call :GetUntilDash
ECHO "%WD_FILE_B%" results in "%SEARCHNAME%"



GOTO :EOF

:GetUntilDash
SET HAYSTACK=%WD_FILE_B%
SET SEARCHNAME=
:GetUntilDash_loop
IF "%HAYSTACK%" EQU "" GOTO :EOF
IF "%HAYSTACK:~0,1%" EQU "-" GOTO :EOF
SET SEARCHNAME=%SEARCHNAME%%HAYSTACK:~0,1%
SET HAYSTACK=%HAYSTACK:~1%
GOTO :GetUntilDash_loop

 




Is that what you are looking for?
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
 
RJG
YaBB Newbies
*
Offline



Posts: 15
Re: Calling all Cli Gurus
Reply #2 - Mar 22nd, 2011 at 1:41am
 
Gert,
 You are awesome, seems to work perfectly, all I had to do to fit it to my existing batch script was change:

IF "%HAYSTACK:~0,1%" EQU "-" GOTO :EOF

to

IF "%HAYSTACK:~0,1%" EQU "-" GOTO :SearchFile
...
...
...


:SearchFile
.. Search code..


I want to thank you properly, for all your help. Not only with this but for that little rar program you whipped up for me.  How can I donate to you directly with paypal?  


Thanks Again Gert, you made my night with this!

WBR


Back to top
 
 
IP Logged
 
RJG
YaBB Newbies
*
Offline



Posts: 15
Re: Calling all Cli Gurus
Reply #3 - Mar 22nd, 2011 at 3:47am
 
Opps may have spoken to soon...

This Works:

In .txt file:

TwoandaHalfMen

The search will will find "TwoandaHalfMen--asdf.." or "Two and a Half Men-asdf.."

This Does NOT work:

In .txt file:

TwoandaHalf

The search will not find the "TwoandaHalfMen--asdf.." video.

The problem that I may run into is that occasionally the full name of the show may not be known.

Not sure if it possible to go both ways with this or not..

Thanks

WBR


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



Posts: 2239
The Netherlands
Re: Calling all Cli Gurus
Reply #4 - Mar 22nd, 2011 at 8:55am
 
Can you post your complete script? I am having trouble understanding exactly what you are doing.
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
 
RJG
YaBB Newbies
*
Offline



Posts: 15
Re: Calling all Cli Gurus
Reply #5 - Mar 22nd, 2011 at 1:29pm
 
Can I PM you the script and PARAM list
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2239
The Netherlands
Re: Calling all Cli Gurus
Reply #6 - Mar 23rd, 2011 at 7:50am
 
Ok, I've looked at it a bit.

So your main problem is that sometimes the WD_FILE_B has a longer showname than is available in SHOWPARM.txt?

Perhaps, after you initially do
Code:
:: Get the Show Params
for /f "tokens=2-9 delims=;" %%A in ('findstr /b /i "%SEARCHNAME%" "C:\FTPSyncFiles\Bat Files\SHOWPARMS.txt"') do (

set sQSF=%%A
set sCOM=%%B
set sPAT=%%C
set sRAR=%%D
set sUPL=%%E
set sSFV=%%F
set sDEL=%%G

)

:: If we Error, lets get out
 if ErrorLevel 1 (
    EXIT
  )
 


You should not EXIT, but try again with a shorter SEARCHNAME? Something like
Code:
:: Get the Show Params
:RetrySearch
if "%SEARCHNAME%" EQU "" EXIT
for /f "tokens=2-9 delims=;" %%A in ('findstr /b /i "%SEARCHNAME%" "C:\FTPSyncFiles\Bat Files\SHOWPARMS.txt"') do (

set sQSF=%%A
set sCOM=%%B
set sPAT=%%C
set sRAR=%%D
set sUPL=%%E
set sSFV=%%F
set sDEL=%%G

)

:: If we Error, try with a shorter search-string
 if ErrorLevel 1 (
    :: remove last char of searchname
    SET SEARCHNAME=%SEARCHNAME:~0,-1%
    GOTO :RetrySearch
  )
 

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