guys. I'm trying to get the file version from inside some nontext files. In each of them (approximately at the beginning) there are a few text lines containing informations about the file. For example:
[some nontext data (very few)]
version: 455467
build date: 23.11.2010
.....
[rest of the nontext data]
If you want I'll try to make such a file but I can't show you the original files (my company won't allow it). Sorry...
I tried this code:
@echo off
for /f "tokens=1,2" %%A in (file.dat) do if %%A==version: (set version=%%B
goto found)
echo not found
goto end
:found
echo found: %version%
:end
pause
But it works only if "file.dat" is a text file, if not I get "not found". If I replace file.dat with 'type file.dat' it does not return (processor usage 100%). If I replace file.dat with 'find /i "version:" file.dat' it works, but it's very, very slow (minutes). Since I have to process many files and I have little time I can't use it. It works a lot faster if I enter each file manually with a viewer and copy version number; but the point is that I want to do it with a cmd...
Oh, and I can't install other programs on the computer where I'm working....
The OS is Windows XP x86.
Please help me. Thank you.
Best regards, Cosmin
Later edit: I have "build" a test file so everybody can see and test: http://www.mediafire.com/download.php?r0x5702lkv14jro It's very small (real files have dozens, some even hundreds of MB).
Later later edit: the test file is useful to test IF the code finds the number but, been very small, it doesn't give you an idea about how much time is needed for a real data file. But you can do this: measure the time in which the test file is scanned and multiply by "100 MB / 2088 Bytes" = 50 219. For example this works with "find". With "type" is even slower (I think it's exponentially, not liniar).