04 August 2011 ~ 0 Comments

DOS Extract Strings from Binary Files

REM ## I needed to get JUST THE STRINGS out of the hex dump of some binary files... Not so easy to do! But I found the awesome Swiss File Knife program here: http://stahlworks.com/dev/swiss-file-knife.html, and threw the sfk.exe into the root directory of a bunch of nasty old files I wanted to tackle.  In this case, the files were 2 levels deep inside of folders that were named the same as their parent folder, as you see here below. You can adjust this in a lot of ways to batch handle really old binary files and extract data that you might actually be able to use today...  By Stacey Tipton Reiman, www.akwebgenius.com/blog ##

@echo off

setlocal ENABLEDELAYEDEXPANSION

set fileout=txts/master_file.txt

for /f %%A in ('dir  /O:N /L /B  /N') do (

set batchdirs=%%A

FOR /F "tokens=1,2 delims=._ " %%A in ( 'dir !batchdirs!\!batchdirs!\ /O:N /L /B  /N *.LSN .CRS .EXE') do (
set filey=%%A
set extension=%%B
echo %%A.%%B
sfk strings !batchdirs!\!batchdirs!\!filey!.!extension! > batch\!batchdirs!\txts\!filey!.txt
rem pause
echo %%A >> !fileout!

)

)

cls
endlocal

The site for that great Swiss File Knife program is here:
Swiss File Knife

Leave a Reply


4 - = three