1

I have a project for my Radio Station where I copy the text within a .wsx file of what is on air and parse it to a Audio Processor in my private network for RDS Display using a wget command like

set /p TEXTO= 0<R:\40.wsx
wget -q "http://x.x.x.x:7380/parameter/fm/rds/rds_rt=%TEXTO%" -O NUL

It works great but it won't filter if it's music or promotions.

My challenge is to be able to filter and only parse music names.

For the process I marked the Files that i don't want to show up like commercial, or promotions to start with a "@-" without the quotes.

So the text will show like @-Promo1

My Code:

for /F "delims=" %%a in ('FINDSTR "\<@-.*"  C:\RDS\PRUEBAS\txt1.wsx') do set 
"VAR=%%a"
  echo %VAR% 
 if "%VAR%" == "true" (
    set /p VAR=0<C:\FILEPATH\LOS40.wsx & wget -q 
"http://x.x.x.x:7380/parameter/fm/rds/rds_rt=%VAR%" -O NUL 
) else (
    set /p TEXTO=0<C:\FILEPATH\ENVIVO.wsx & wget -q 
"http://x.x.x.x:7380/parameter/fm/rds/rds_rt=%TEXTO%" -O NUL
)

I can't seem to find a correct way to filter it.

pls Heelpp..

Raul Vence
  • 13
  • 2
  • ?... I don't see, how the result of a `FINDSTR "\<@-.*"` could ever be `true`. If you just want to check, if your string is in a file or not, you don't need a `for`. Just `findstr "\<@-.*" C:\RDS\PRUEBAS\txt1.wsx >nul && ( echo does contain the string ) || ( echo does NOT contain the string )` – Stephan Nov 16 '17 at 19:04

2 Answers2

1
for /F "delims=" %%a in ('FINDSTR "\<@-.*"  C:\RDS\PRUEBAS\txt1.wsx') do set 

should be

for /F "delims=" %%a in ('FINDSTR /b "@-"  C:\RDS\PRUEBAS\txt1.wsx') do set 

to find those lines in the .wsx file that do /b begin with "@-"

If you want to find those lines that do not begin with "@-" then add /v to the /b.

The result will be a line from the file which does [not] begin with "@-" which will be placed in %%a.

If you simply assign %%a to a variable as you are doing, that variable will contain after the for the last value that was assigned to it.

If you want to execute your wget on each name, then use

for /F "delims=" %%a in ('FINDSTR /B "@-"  C:\RDS\PRUEBAS\txt1.wsx') do (
 echo %%a
)

and between the parentheses you can execute commands using %%a as a filename.

Quite what you propose to do is obscure. I've no idea what the set/p from an unexplained file is meant to do, but be aware that any code between parentheses is subject to the delayedexpansion trap - please explain what processing you intend to apply to the filenames that do[not] match a leading @-.

You should read SO items on delayed expansion (it's documented with and without the space) to understand the problems with and solutions to processing values that are altered within a loop.

Magoo
  • 77,302
  • 8
  • 62
  • 84
0

First of all thanks for your help.. I don't have experience in coding.

Let me explain a little bit more..

As I said before its a radio station which will provide text to the Car o home stereos using the RDS Protocol which allow me to send text like song name, title, etc.

Im My case the Audio Processor that let me send the text will receive the info as a URL where I add at the end the text I want to send.

For Example:

http://x.x.x.x:7380/parameter/fm/rds/rds_rt=%TEXTO%

%TEXTO% will be the text Im sending.

C:\RDS\PRUEBAS\txt1.wsx Contains the text of what it being played at the moment and which is being read to see if the @- for the script to avoid sending those titles.

I have a Pc running a Directory Monitor Program that will monitor events on file C:\RDS\PRUEBAS\txt1.wsx and that as soon as being modified, it will execute the batch file CHECKRDS.cmd.

After testing I decided to run a code in CHECKRDS.cmd like:

for /F "delims=" %%a in ('FINDSTR /v "@-"  R:\40PPALES.wsx') do (
  START "" RDS.bat
 )
EXIT

RDS.bat contains code and it works fine:

set /p TEXTO= 0<C:\RDS\PRUEBAS\txt1.wsx
wget -q "http://x.x.x.x:7380/parameter/fm/rds/rds_rt=%TEXTO%" -O NUL
EXIT

As far as the set /p I test it from What does /p mean in set /p?

AS I said before Im new at coding and I just googled everything and started to assable the pieces of the puzzle.

Pls, If you think I should be doing these process diferently, pls let me know..

And sorry for my bad english..

regards

Raul Vence
  • 13
  • 2