压缩指定后缀

2016年1月11日 0 条评论 1.68k 次阅读 0 人点赞
@echo off&setlocal enabledelayedexpansion
::将当前目录下的exe文件添加到rar压缩文件
::请将winrar目录下的rar.exe放置到windows目录下
:: 2008-1-5 [email protected]
:: by lf
title 压缩指定后缀名
color 8b
set name=%0
rar a -id[c,d] "%~n0.rar%" !name! >nul 2>nul && (
    del /q "%~n0.rar"
    echo.
    set/p a=请输入需要压缩的后缀名(例:exe):
    goto :yasuo
)
echo 请将winrar目录下的rar.exe放置到windows目录下..&pause>nul
goto :eof

:yasuo
set work=rar a -id[c,d] -ep1
set /p an=是否删除源文件?(y/n):
if /i "!an!"=="y" set work=!work! -df
for /f "tokens=*" %%i in ('dir/b/s *.!a!') do (
    set r=%%~dpni.rar
    set e=%%~dpni.!a!
    if not exist "!r!" (!work! "!r!" "!e!") else (echo 存在同名!r!...)
)
echo 压缩完毕..&pause>nul
goto :eof

Sevenfal

这个人太懒什么东西都没留下

文章评论(0)