I have a script in which I read html files which I want to edit. Here I paste the code which calls :remove_redundant_columns subroutine.
It should remove the spaces/white spaces from begin of each line and remove from html file. Only problem is that it adds extra text like = to lines which are almost empty, just have few tabs.
The html file which I downloaded is from hidemyass.com/proxy-list/1
call parse_proxy.bat remove_redundant_columns !FILENAME!
exit /b
:remove_redundant_columns
REM Remove whitespaces from begin of lines and <span></span>
FOR /f "tokens=*" %%t in (%1) do (
SET S=%%t
SET S=!S:^<span^>^</span^>=!
if NOT "!S!"=="" >>$tmp$ echo !S!
)
del %1
REN $tmp$ %1
exit /b
If you believe, that’s your only problem… You need to check, if your variable S contains content.
That’s required, as substitution on an undefined variable will not produce an undefined/empty variable, the new content will be the substitution text.
As dbenham stated, you got many other problems,
and one additional problem is the
echo !S!command itself.ECHOhas some nasty side effects on different content.If the content is empty (or only spaces) then it will print it’s currently state
ECHO IS OFFIf the content is
OFForONit will NOT be echoed, it will only change the state.And if the content is
/?it will echo the help instead of/?.To solve this you could simply change
ECHO !S!toECHO(!S!and all problems are gone.