我的要求是创建一个具有以下格式的输出文件: 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