I'm writing a batch file to help my wife with her work.
She searches her work's site for content that needs to be removed. They won't help her with the tools to do it easier so she has enlisted me.
She'll find the site that has the questionable content, view and download the source code and pick out the image numbers that are in the links. So she came to me to write a script that will search through the html source code and pull the image numbers. I have her save the source html as 'test.txt' in the folder that has the .bat file. This is what I have so far:
So it takes the source and FIND spits out the lines that have the image number and writes it to temp.txt. Then the FOR command spits out just the image numbers to temp2.txt but because of the HTML there are duplicate numbers.
So then I run it through FIND again this time printing only the lines that don't have ">" and cat out the final product to output.txt. Which is good except for the trailing "
How do I get rid of the trailing "?
I've tried: (test version here)
But that won't do it. I get
Any ideas?
She searches her work's site for content that needs to be removed. They won't help her with the tools to do it easier so she has enlisted me.
She'll find the site that has the questionable content, view and download the source code and pick out the image numbers that are in the links. So she came to me to write a script that will search through the html source code and pull the image numbers. I have her save the source html as 'test.txt' in the folder that has the .bat file. This is what I have so far:
Code:
@echo off & setLocal EnableDelayedExpansion :start cls echo.------------------------------------ echo Image Number Finder Script echo.------------------------------------ echo. echo Have you saved the new source 'test.txt' file? echo. pause cls echo ------------------------------------------------------------------- echo The saved source file will contain long strings of markup language. echo The desired image number is contained in the image links. echo For instance you might want '453465759' and all of the other image numbers echo but the line contains: echo. echo WORKSITE.com+crappy_item,453465759 echo. echo Look in the source file to get an idea of what to search for. echo In this case you can use 'item,4' to get a list of all image numbers echo for the items in the source file. echo ------------------------------------------------------------------- echo. set /p input=Please type the search parameter. (like 'item,4'): find /i "%input%" test.txt > backend\temp.txt for /f "tokens=3 delims=, " %%i in (backend\temp.txt) do ( @echo %%i )>>"backend\temp2.txt" find /v ">" backend\temp2.txt > output.txt del backend\temp.txt del backend\temp2.txt cls echo.--------------------------------------------------------- echo The output has been saved to 'output.txt' in this folder. echo.--------------------------------------------------------- pause
Code:
441268137" 441268137">
Code:
---------- BACKEND\TEMP2.TXT 441268137" 442100756" 441324019" 441324212" 442551649" 442099657" 441269573" 441269402" 442100566"
I've tried: (test version here)
Code:
@echo off & setLocal EnableDelayedExpansion :start cls for /f "eol=-" %%i in (output.txt) do ( set output=%%i set output=!output:~0,-1! echo %output% ) >> output2.txt
Code:
ECHO is off. ECHO is off. ECHO is off. ECHO is off. ECHO is off. ECHO is off.


Comment