1

我的要求是创建一个具有以下格式的输出文件: Filename,file size,checksum

一个例子是abc.tar,1024 Bytes,052107adc8c42d6cf581bf81225ae6de

代码

setlocal enabledelayedexpansion  
set OUTFILE="C:\Script\Batch_OUT.txt"

echo %OUTFILE%

echo Extracting Batch records to %OUTFILE% ...
echo pwd = `pwd`

cd C:\Script\TARS\

for %%f in (Batch_*.tar) do (  
(echo %%~nxf && echo %%~zf Bytes && certutil -hashfile "%%f" MD5 | find /V    ":") >>%OUTFILE%  
) 

pause 2m

输出

Batch_one.tar 
778240 Bytes 
052107adc8c42d6cf581bf81225ae6de

预期结果

Batch_one.tar,778240 Bytes,052107adc8c42d6cf581bf81225ae6de
4

1 回答 1

0

您可以使用与帖子中相同的技巧,David Winder 已在评论中链接:

...
for %%f in (test.txt) do (  
 (
   <nul set /p ".= %%~nxf,%%~zf Bytes," 
   certutil -hashfile "%%f" MD5 | find /V ":"
 ) >>%OUTFILE%  
) 
...
于 2018-09-05T15:10:06.407 回答