|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
兄别着急,我在我这里正在测试(怕万一出个错误删掉兄的文件可麻烦了:),有更短的命令可以完成,一会我发上来:)
Brother, don't worry. I'm testing here (in case an error deletes your files, that would be a hassle:)), there's a shorter command that can do it, I'll post it later:))
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2007-2-7 03:36 |
|
|
qingfushuan
高级用户
   
积分 502
发帖 327
注册 2006-12-30
状态 离线
|
『第 17 楼』:
我试了试
使用 LLM 解释/回答一下
我试了试:
for /f %%a in ('dir /b /s') do rar a /r /sfx %%a "%%a"
好像可以满足要求,但是得把rar.exe和Default.SFX放在一块,直接就是自解压文件
希望对你有帮助
I tried:
for /f %%a in ('dir /b /s') do rar a /r /sfx %%a "%%a"
It seems to meet the requirements, but you need to put rar.exe and Default.SFX together, and it will be a self-extracting file directly.
Hope it helps you
|
|
2007-2-7 03:41 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
回txtrain兄:
执行下面命令前(一劳永逸)需要设置初始值:
1)给 Winrar.exe 所在的目录设置路径,让系统可以找得到。
如果觉得麻烦,可以将 WinRAr.exe 拷贝到 Windows 目录内,这样省去了手工设置路径的麻烦:)
2)将 \Program Files\WinRAR\ 目录内的 Default.SFX 这个文件拷贝到 Windows 目录内。
这是 Winrar 或 RAR 在压缩自解压文件时所要读取的一个“字典”文件,如果不将其拷贝到已设置好的路径中,则压缩时找不到,也就压缩不了。
拷贝了这个文件到 Windows 目录内,以后就可以一个压缩命令一步完成 .exe 自解压文件的建立。
命令行直接键入:
for /f %i in ('dir /b /ad') do winrar a /r /m5 /sfx "e:\bak\%i.exe" "%i"
将当前目录下的 下一级目录以及在内的所有文件 压缩成自解压(.EXE)格式,并将压缩成的 .exe 文件存到 E:\BAK 目录中。
DIR /AD 是只列目录,滤掉文件。
如果只有 dir /b 的话,则会连文件与目录名全都被 for 枚举出来。
我在%i 参数以及操作时均加有双引号,这样当遇到含有空格的目录名时照样可以工作,而不会出错。
如果不加双引号,则遇含有空格的文件名时又正遇到 MD 或 RD 等危险命令时很可能会发生意想不到的意外……
我这里通过测试:)
版本: RAR 3.0 未注册版,Windows 2003
Last edited by redtek on 2007-2-6 at 02:52 PM ]
Reply to txtrain brother:
Before executing the following command (once and for all), you need to set initial values:
1) Set the path for the directory where Winrar.exe is located so that the system can find it.
If you find it troublesome, you can copy WinRAr.exe to the Windows directory, which saves the trouble of manually setting the path :)
2) Copy the Default.SFX file in the \Program Files\WinRAR\ directory to the Windows directory.
This is a "dictionary" file that Winrar or RAR needs to read when compressing a self-extracting file. If this file is not copied to the set path, it will not be found during compression, and thus cannot be compressed.
After copying this file to the Windows directory, you can then complete the creation of the .exe self-extracting file in one compression command.
Type directly in the command line:
for /f %i in ('dir /b /ad') do winrar a /r /m5 /sfx "e:\bak\%i.exe" "%i"
Compress the next-level directories and all files within them in the current directory into a self-extracting (.EXE) format, and store the compressed .exe file in the E:\BAK directory.
DIR /AD is to list only directories and filter out files.
If there is only dir /b, then both files and directory names will be enumerated by for.
I have added double quotes to the %i parameter and during operation, so that it can work normally when encountering directory names with spaces without errors.
If double quotes are not added, unexpected accidents may occur when encountering file names with spaces and encountering dangerous commands such as MD or RD...
I tested here :)
Version: RAR 3.0 unregistered version, Windows 2003
Last edited by redtek on 2007-2-6 at 02:52 PM ]
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2007-2-7 03:49 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
非常感谢qingfushuan兄指点~:)))
Thanks a lot for the guidance from brother qingfushuan~:)
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2007-2-7 03:51 |
|
|
qingfushuan
高级用户
   
积分 502
发帖 327
注册 2006-12-30
状态 离线
|
『第 20 楼』:
呵呵
使用 LLM 解释/回答一下
我还是菜鸟的哈,从无忧泡到联盟就是想学习for的哦,谢谢LZ提供感兴趣的题材
实际上LZ已经完成了的,只是没用rar /? 咨询罢了,不敢窃天之功啊,我的关机脚本
就有:start c:\Progra~1\WinRAR\rar.exe a /r /s /m1 f:\mybackup\bak\%date%.rar f:\mybackup\backup 这一句,因而熟悉点
Last edited by qingfushuan on 2007-2-6 at 03:29 PM ]
I'm still a newbie. I came from Wuyou to the union just to learn about for. Thanks to the LZ for providing the interesting topic.
Actually, the LZ has already completed it, just consulting about rar /?. I don't dare to take credit. My shutdown script has: start c:\Progra~1\WinRAR\rar.exe a /r /s /m1 f:\mybackup\bak\%date%.rar f:\mybackup\backup This sentence, so I'm more familiar with it.
Last edited by qingfushuan on 2007-2-6 at 03:29 PM ]
|
|
2007-2-7 04:25 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
qingfushuan兄客气啦:)
我在眼里没菜鸟,每个人都有数不尽可以学习的地方~:)))
Brother qingfushuan, you're too kind. : )
In my eyes, there are no beginners. Everyone has countless things to learn. : ) ) )
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2007-2-7 04:38 |
|
|
txtrain
初级用户
 
积分 28
发帖 12
注册 2007-1-19
状态 离线
|
『第 22 楼』:
感谢二位大哥
使用 LLM 解释/回答一下
刚好,小弟最后那一帖子在十五楼,没看到 还有第二页不好意思.感谢你们为我这个问题所花费的时间.这是无价的.但是不完美的地方是E:\temp>for /f %a in ('dir /b /ad') do winrar a /r /sfx /m5 "e:\temp\%a.exe" "%a
"这一句一执行,会同时打开N个压缩文件进行压缩,试想一下,如果N够大的话.肯定会机器垮掉,而且有可能因为机器过忙压缩好的文件会出现压缩错误的情况
不捉迷藏了,这样就可以解决了.
for /f %a in ('dir /b /ad') do start /w winrar /a /r /sfx /m5 "e:\temp\%a.exe" "%a"
还有为了分享,我告诉大家一点经验.有时候压缩大文件的时候,可能会出现CRC失败之类的信息,这个时候压缩的时候选择压缩方式"最好"."创建固实压缩"一般可以解决问题.如果还是不能解决,呵呵,换个服务器版本的操作系统试试,这是小弟郁闷很久后的一点心得,拿出来省的大家再走弯路.
还有一点要求讲解的是,为什么那个for 语句最后面还要再跟一个"%a"呢?
Last edited by txtrain on 2007-2-6 at 05:43 PM ]
Just right, my last post is on the fifteenth floor, I didn't see it. There's also the second page, sorry. Thank you all for the time you spent on this problem for me. It's invaluable. But the imperfect place is that when this line "E:\temp>for /f %a in ('dir /b /ad') do winrar a /r /sfx /m5 "e:\temp\%a.exe" "%a"" is executed, N compressed files are opened for compression at the same time. Imagine that if N is large enough, the machine will definitely crash, and there may be compression errors because the machine is too busy compressing.
No more beating around the bush, this way it can be solved.
for /f %a in ('dir /b /ad') do start /w winrar /a /r /sfx /m5 "e:\temp\%a.exe" "%a"
Also, for sharing, I tell you some experience. Sometimes when compressing large files, there may be information like CRC failure. At this time, choosing the compression method "Best" and "Create solid compression" when compressing can generally solve the problem. If it still doesn't work, heh heh, try changing to a server version of the operating system. This is a little experience that I've been depressed about for a long time, and I take it out to save everyone from going the wrong way again.
There's another point to explain, why does that for statement have to follow another "%a" at the end?
Last edited by txtrain on 2007-2-6 at 05:43 PM ]
|
|
2007-2-7 06:23 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
有了qingfushuan兄和txtrain兄对WinRAR的经验之谈,以后网友再解决一些关于压缩方面的问题看此帖参考相关内容就再方便不过啦~:)
【 正文检索主题词: RAR WINRAR 压缩 压缩文件 压缩目录 Default.SFX /W /WAIT 】
Last edited by redtek on 2007-2-6 at 06:21 PM ]
With the experience talk about WinRAR from brother qingfushuan and brother txtrain, it will be much more convenient for netizens to refer to relevant contents in this post when solving some compression - related problems in the future ~ : )
【 Main text retrieval subject words: RAR WINRAR compression compressed file compressed directory Default.SFX /W /WAIT 】
Last edited by redtek on 2007-2-6 at 06:21 PM ]
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2007-2-7 07:15 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 24 楼』:
使用 LLM 解释/回答一下
Originally posted by txtrain at 2007-2-6 17:23:
有时候压缩大文件的时候,可能会出现CRC失败之类的信息,这个时候压缩的时候选择压缩方式"最好"."创建固实压缩"一般可以解决问题
欣赏txtrain兄经验之谈,学习了~:)
收藏~:)
Last edited by redtek on 2007-2-6 at 06:24 PM ]
Originally posted by txtrain at 2007-2-6 17:23:
Sometimes when compressing large files, you may encounter messages like CRC failure. At this time, select the compression method "Best" when compressing. "Create solid compression" can generally solve the problem.
Appreciate the experience sharing from兄txtrain, learned it~:)
Collected~:)
Last edited by redtek on 2007-2-6 at 06:24 PM ]
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2007-2-7 07:23 |
|
|