Windows批处理文件-单行格式化CertUtil输出以及文件名和大小

时间:2018-09-05 12:40:11

标签: batch-file certutil

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

1 个答案:

答案 0 :(得分:0)

您可以使用与post中相同的技巧,但大卫·温德(David Winder)已经在评论中链接了

fetchData(){
    console.log('%c fetching now', 'border: 2px dashed purple');

    // this.initLoader();

    this.dataFetched$ = Observable.combineLatest([
        this.heroTableService.getHeroTableData([SubAggs.allNetworks.key], AggFieldsMap.legends.name),
        this.researchService.benchmark(this.getSubAggsForOverviewTbl()),
        this.multiLineChartService.getEngagementOverTime(this.getSubAggsForNetworkEngagementsOverTimeTable())
    ]).pipe(
        share(),
        delay(7000),
        tap(v => {
            console.log('%c fetch data emit', 'border: 2px dashed orange', v);
        })
    );


    const sub = this.dataFetched$.subscribe(([heroTableRes, benchmarkRes, netByEngRes]: [ITable[], IBenchmarkResponse, any]) => {
         // this.loading = false; ==> moved to dashboard

         //xavtodo: split this shit into .do() or .tap under each http request call
         //hero table logic here
         this.heroTableData = heroTableRes;

         //////////////////////////////////////////////////////
         //engagement-by-network-table
         this.engagementByNetworkData = this.researchService.extractDataForEngagementByNetworkTable(benchmarkRes, this.getSubAggsForOverviewTbl());

         //////////////////////////////////////////////////////
         //network eng over time logic here MULTI LINE CHART
         this.engagementMultiLineData = this.multiLineChartService.extractEngagementData(netByEngRes, this.getSubAggsForNetworkEngagementsOverTimeTable());
         this.networks = this.multiLineChartService.getNetworks();
         this.multilineChartEngagements = Util.getNetworksWithAltNames(this.networks);
         this.publishedContentData = this.multiLineChartService.extractPublishedData(netByEngRes);

         //combined multiline chart
         this.multiLineChartData = {
             publishedData: this.publishedContentData,
             engagementData: this.engagementMultiLineData
         };
     });

    this.addSubscription(sub);
}