Better Way to Do This

May 19, 2009 at 10:26:36
Specs: Windows XP
Im trying to find the best way of handling the results a find command, i want to see if theres away to pipe the results straight to a variable instead of going through a temp file.

I need the command to search a file for the text "DVL error" and if it exists then it needs to send a variable to another text file, however i'm having some issues.

I've only been doing batch scripting for around 4 days last time i did any was about 7 years ago.

Heres the script snippet:

	:: Check to see if we got a DVL error and if so send this spot to our results list
	for %%a in (%downloadTo%\testspot.txt) do find "DVL error" < %%a >> %downloadTo%\temp.txt
	for %%a in (%downloadTo%\temp.txt) do (
		SET "resultsInFile=%%a"
		IF "%resultsInFile:~,9%" == "DVL error" echo %spotName% >> %downloadTo%\%boxName%_results.txt 
		echo %resultsInFile:~,9%
	)

If the temp.txt file looks like this the script should pick up a match:

DVL error 13: specified video file does not exist

The only other state for this file should be that its empty.

Right now whats happening is that the script is printing this:
C:\temp\t

Which means that its not seeing whats in the file itself just the name of the file itself.


See More: Better Way to Do This

Report •


#1
May 19, 2009 at 11:58:19
sorry that snippet doesnt work correctly however this one does

	for %%a in (%downloadTo%\testspot.txt) do find "DVL error" < %%a >> %downloadTo%\temp.txt
	for /F "tokens=*" %%a in (%downloadTo%\temp.txt) do (
		SET "resultsInFile=%%a"
		IF "%resultsInFile:~,9%" == "DVL error" echo %spotName% >> %downloadTo%\%boxName%_results.txt 
		echo "%%a" "%resultsInFile:~,9%"
	)


Report •
Related Solutions


Ask Question