![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-13 13:38 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS学习入门 & 精彩文章 (教学室) » for call winrar batch generate compressed files everyone help take a look |
| Printable Version 3,292 / 23 |
| Floor1 txtrain | Posted 2007-02-06 23:02 |
| 初级用户 Posts 12 Credits 28 | |
|
The purpose is like this:
I have many folders in the current directory, and different folders and files are placed in them, with sizes ranging from a few megabytes to hundreds of megabytes. I just want to take the current directory as the benchmark, enter the directory, compress, make a self-extracting archive, delete the compressed archive, exit the folder, and so on in a loop until all folders are compressed. The environment variables for calling WinRAR and the relevant WinRAR parameters have been set (because it is set to take effect for the graphical interface, so it must be done by calling WinRAR), and it can be called directly. This is what I wrote: for /f %a in ('dir /b') do cd %a &winrar a -r x:\%a.rar&winrar s x:\%a.rar&del x:\%a.rar&cd.. That's it. But in the actual execution process, the second WinRAR command is executed before the first one is finished! Because the workload is very large, so I'm really troubled. Please give me some advice. I have repeatedly experimented many times. Using the echo statement to generate a batch file must work, but I want to go further and just have one command, expert advice. Thank you! [ Last edited by txtrain on 2007-2-6 at 10:15 AM ] |
|
| Floor2 redtek | Posted 2007-02-06 23:22 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
Replace with RAR.EXE in the WinRAR directory for parameterized compression (command line interface).
In this way, when the brother executes the compression task, RAR.exe will complete the current task first, and then the subsequent commands will be executed, so that the work of compressing first and then converting can be carried out normally~:) "Among them, about the environment variables for calling WinRAR and related WinRAR parameters (because the settings take effect for the graphical interface, so WinRAR must be called to complete)", Copy the rar.exe file to the Windows directory (because the environment variable already contains the Windows path), so that RAR.EXE can be directly called anywhere~:) (This can save the setting of manually adding the path where rar.exe is located) [ Last edited by redtek on 2007-2-6 at 10:44 AM ] |
|
| Floor3 txtrain | Posted 2007-02-06 23:51 |
| 初级用户 Posts 12 Credits 28 | |
|
I tried using RAR before and it must have been fine, but WinRAR has a parameter called "Compression method": Best: I need this one, but it seems I can't find this parameter in RAR.
|
|
| Floor4 redtek | Posted 2007-02-07 00:00 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
m<0..5> Set compression level (0=store...3=default...5=maximum)
rar a /r /m5 ..... The M5 parameter is maximum ratio compression:) |
|
| Floor5 txtrain | Posted 2007-02-07 00:06 |
| 初级用户 Posts 12 Credits 28 | |
|
Then, what is the best compression method in WinRAR, 0 or 5? I can't figure it out.
|
|
| Floor6 redtek | Posted 2007-02-07 00:13 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
Winrar with the /m5 parameter is the maximum compression ratio :)
Use winrar a /r /m5 ... and Winrar a /r /m0 ... respectively to compare compressing the same directory, they differ a lot, and the compression ratio with the /m5 parameter is the largest :) [ Last edited by redtek on 2007-2-6 at 11:14 AM ] |
|
| Floor7 txtrain | Posted 2007-02-07 00:15 |
| 初级用户 Posts 12 Credits 28 | |
|
That is to say, 0 is the best for compression? Actually, you can just set it directly with WinRAR, why add any parameters? The reason I've always wanted to adjust WinRAR directly is because I can set it directly. No need to add parameters
[ Last edited by txtrain on 2007-2-6 at 11:16 AM ] |
|
| Floor8 redtek | Posted 2007-02-07 00:23 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
WinRAR (/M5 parameter can maximize compression and compress files to the smallest possible size:)
Calling WinRAR is really good~:) But I like the command line, not so much the graphical interface (mainly because typing is fast, haha) |
|
| Floor9 txtrain | Posted 2007-02-07 00:29 |
| 初级用户 Posts 12 Credits 28 | |
|
I'm going crazy, Redtek. Did you test it in your own environment?
for /l %a in (1,1,9) do @echo %a >>%a.txt for /l %a in (1,1,9) do mkdir %a for /l %a in (1,1,9) do move %a.txt %a\ Then copy some other folders and files into those directories and try compressing. for /f %a in ('dir /b') do cd %a&&rar a /r x:\%a.rar&&winrar s x:\%a.rar&&del x:\%a.rar&&cd .. You can see what the result is yourself. I always forgot to mention that my test environment is XP SP2. WinRAR version: RAR 3.50 beta 3 Copyright (c) 1993-2005 Alexander Roshal 22 Apr 2005 Registered to - Internet - [ Last edited by txtrain on 2007-2-6 at 11:37 AM ] |
|
| Floor10 redtek | Posted 2007-02-07 00:47 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
Compression Test of NOTEPAD.EXE:
2007-02-06 11:48 34,459 n1.rar (This is compressed with /M5, which is the best) 2007-02-06 11:48 65,606 n2.rar (This is compressed with /M0) WRAR 3.0 Unregistered Version System: Name: WindowsServer 2003, Enterprise Edition Version: 5.2 Build 3790 [ Last edited by redtek on 2007-2-6 at 11:49 AM ] |
|
| Floor11 vkill | Posted 2007-02-07 00:51 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
I like 7z under the command line
|
|
| Floor12 anqing | Posted 2007-02-07 01:01 |
| 高级用户 Posts 413 Credits 859 | |
|
I'll help you push it up. I also want to figure out your question.
|
|
| Floor13 txtrain | Posted 2007-02-07 02:16 |
| 初级用户 Posts 12 Credits 28 | |
|
I think my problem is precisely that when I call two external commands consecutively, the latter one doesn't wait for the former to finish executing.
|
|
| Floor14 redtek | Posted 2007-02-07 02:33 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
Originally posted by txtrain at 2007-2-6 13:16: I'm sorry, just now I only focused on discussing the compression ratio and forgot to stay on topic : ) In this way, only after the WinRAR compression task is completed will it continue to execute the following commands downwards : ) Brother can write the compression command and the command to convert the .rar file to a self-extracting one in two separate lines, instead of connecting them as one line with &. In this way, the Start /w parameter can make them execute one after the other instead of executing concurrently : ) That is: In this way, the second command will not be executed until the first command is completed : ) Could it be that I'm off topic again? The above is that the latter command waits for the former command to finish executing before executing : ) Brother said that "continuously calling two external commands, the latter one does not wait for the former one to finish executing before executing", not waiting for the former one to finish executing means running concurrently, right? Start First command Start Second command [ Last edited by redtek on 2007-2-6 at 01:38 PM ] |
|
| Floor15 txtrain | Posted 2007-02-07 02:39 |
| 初级用户 Posts 12 Credits 28 | |
|
I can tell you responsibly, tried it, didn't work
Dizzy, tried again and it worked, it seems my actual work is still not in place, thanks!!! [ Last edited by txtrain on 2007-2-6 at 01:53 PM ] |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |