我需要将文件压缩为gunzip,并通过以下命令
完成@echo off gzip -c C:\ temp1 \ xx.out> C:\ TEMP2 \ x2.out.gz
但我的目的是检查扩展名为.out的目录中的所有文件,并将每个文件压缩为gunzip文件,并在压缩完成后删除相同的文件。请告诉我如何在批处理脚本中完成
答案 0 :(得分: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
)