batch file - for /f: Read input with various delimiters -


i using gpg (or 7-zip) generate hashsums of files. want read these hashsums variables in batch file work them further.

my problem gpg creates -based on path length , chosen hashalgo- different output:

sha256, short path:

c:\test.txt: e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b          7852b855 

md5, short path:

c:\test.txt: d4 1d 8c d9 8f 00 b2 04  e9 80 09 98 ec f8 42 7e 

sha256, long path:

c:\folder1\folder2\folder3\testfile-longname.ext1.txt:  764b2054 853b6bcc 919853dd d47f4a3a f5a2dfb1 a5ee6967 52051e1e 12b143cc 

7-zip gives following output when using crc32 , sha256 file:

7-zip (a) [64] 16.04 : copyright (c) 1999-2016 igor pavlov : 2016-10-04 scanning 1 file, 296533469 bytes (283 mib) crc32    sha256                                                           size           name -------- ---------------------------------------------------------------- -------------  ------------ bb280ec2 22b8ab1b1ad2f04a47bfd409997a834b30c617b619522381123b7d2ad8f724f9 123456789      testfile-longname.ext1.txt -------- ---------------------------------------------------------------- -------------  ------------ bb280ec2 22b8ab1b1ad2f04a47bfd409997a834b30c617b619522381123b7d2ad8f724f9     296533469   size: 123456789 crc32  data:              bb280ec2 sha256 data:              22b8ab1b1ad2f04a47bfd409997a834b30c617b619522381123b7d2ad8f724f9 

unfortunately can not make predictions path length , hashalgo used, can program used (gpg or 7-zip).

i tried various settings in delims , tokens for /f unable catch md5 , sha256 reliably in gpgs output , crc32 (and perhaps sha256) in 7-zips output.

thanks help!

clarification: gpg have problem different output formats unable checksum. when using 7-zip uable extract checksums large (unimportant) parts of output.

for example of output gave, try this:

for /f "tokens=1,2,3,4 delims=: " %a in ('type foobar.txt ^| findstr "data"') echo %d 

where foobar.txt contains output of command, replace type foobar.txt command.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -