中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-09 12:02
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 把每个文件放在单独的压缩包中 用DOS批处理做 查看 714 回复 5
楼 主 把每个文件放在单独的压缩包中 用DOS批处理做 发表于 2008-08-10 10:59 ·  中国 山东 淄博 桓台县 联通
新手上路
积分 8
发帖 2
注册 2007-02-06 12:17
19年会员
UID 78787
性别 男
状态 离线
假设有10个文件,要做成10个压缩包,每个文件放在单独的压缩包中,用DOS批处理做 ……

[ Last edited by linuxzhen on 2008-8-10 at 11:00 AM ]
2 发表于 2008-08-10 11:50 ·  中国 江西 吉安 遂川县 电信
中级用户
★★
积分 253
发帖 112
注册 2006-05-31 11:12
20年会员
UID 56308
性别 男
状态 离线
for + rar.exe
或单独rar.exe也可以完成
3 发表于 2008-08-10 12:00 ·  中国 广东 广州 电信
银牌会员
★★★
永远的菜鸟
积分 1,335
发帖 574
注册 2007-11-27 12:50
18年会员
UID 103929
性别 男
来自 广西
状态 离线
其实rar有命令行帮助的,自己看会更明白些

@echo off
rem 如果rar的安装目录不一样,请作相应更改
set rar_="c:\program files\winrar\rar.exe"
for %%a in (*.*) do (
if not "%%a"=="%~0" (%rar_% a "%%~na.rar" "%%a")
)
4 发表于 2008-08-19 07:34 ·  中国 广东 东莞 电信
中级用户
★★
积分 461
发帖 243
注册 2007-10-14 16:56
18年会员
UID 99730
性别 男
状态 离线
if not "%%a"=="%~0" (%rar_% a "%%~na.rar" "%%a")
)

请教这里的"%%~na.rar"是生成的新的rar文件,"%%~na表示什么?前面语句没有%%~n
5 发表于 2008-08-19 09:33 ·  美国 惠普HP
版主
★★★★★
积分 9,023
发帖 5,017
注册 2007-05-31 19:39
19年会员
UID 89899
性别 男
状态 离线
看看帮助
for /?
In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:

%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string

The modifiers can be combined to get compound results:

%~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only
%~fsI - expands %I to a full path name with short names only
%~dp$PATH:I - searches the directories listed in the PATH
environment variable for %I and expands to the
drive letter and path of the first one found.
%~ftzaI - expands %I to a DIR like output line
6 发表于 2008-08-19 09:38 ·  中国 广东 东莞 电信
中级用户
★★
积分 461
发帖 243
注册 2007-10-14 16:56
18年会员
UID 99730
性别 男
状态 离线
谢谢
论坛跳转: