【问题标题】:Compression of a file in batch script在批处理脚本中压缩文件
【发布时间】:2013-11-20 22:27:04
【问题描述】:

我需要将一个文件压缩成gunzip,它是通过下面的命令完成的

@echo 关闭 gzip -c C:\temp1\xx.out > C:\temp2\x2.out.gz

但我的要求是检查扩展名为 .out 的目录中的所有文件,并将每个文件压缩为 gunzip 文件,并在压缩完成后删除相同的文件。请让我知道如何在批处理脚本中完成

【问题讨论】:

    标签: batch-file


    【解决方案1】:
       rem Pick up each file in C:\Temp1\ with .out extension.
       for %%a in ("C:\temp1\*.out") do (
    
            rem Compress the file to a file with the same name but .gz extension is added.
            gzip -c %%a > %%a.gz
    
            rem Delete the .out file which has been already compressed.
            del /F /Q %%a
        )
    

    【讨论】:

    • 最好稍微解释一下您的答案。工作之谜仍然是谜
    猜你喜欢
    • 1970-01-01
    • 2013-12-27
    • 1970-01-01
    • 2022-11-03
    • 1970-01-01
    • 1970-01-01
    • 2022-06-15
    • 1970-01-01
    • 2012-06-21
    相关资源
    最近更新 更多