为什么使用 WinRAR 归档文件夹的批处理文件需要比预期更长的时间才能完成?
我有一个脚本,它将所有文件夹和文件从 c:\projects
目录移动到 c:\backup
中的 RAR 存档中。
for /f "delims==" %%D in ('DIR C:\projects /A /B /S') do (
"C:\Program Files\WinRAR\WinRAR.EXE" m -r "c:\backup\projects.rar" "%%D"
)
我还尝试了以下脚本,它使用相同的源 c:\projects
,但为 c:\projects
中的每个文件夹创建一个单独的存档: \备份。
FOR /F "DELIMS==" %%D in ('DIR C:\projects /AD /B') DO (
"C:\Program Files\WinRAR\WinRAR.EXE" m -r "C:\Backup\%%D.rar" "%%D"
)
第二个脚本只需要两个小时即可运行,而我的第一个脚本则需要 24 小时以上才能运行。
有什么办法可以让我的第一个脚本更快吗?
我的第一个脚本不应该更快吗?
I have this script which moves all my folders and files from my c:\projects
directory into a RAR archive in c:\backup
.
for /f "delims==" %%D in ('DIR C:\projects /A /B /S') do (
"C:\Program Files\WinRAR\WinRAR.EXE" m -r "c:\backup\projects.rar" "%%D"
)
I have also tried the below script which uses the same source c:\projects
, but creates a separate archive for each folder in c:\projects
in c:\backup
.
FOR /F "DELIMS==" %%D in ('DIR C:\projects /AD /B') DO (
"C:\Program Files\WinRAR\WinRAR.EXE" m -r "C:\Backup\%%D.rar" "%%D"
)
This second script only takes two hours to run while my first script takes over 24 hours to run.
Is there any way to make my first script faster?
Shouldn't my first script be faster at all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的猜测是,您的“c:\backup\projects.rar”存档是一个可靠的存档,这意味着每次向其中添加内容时都需要完全重新打包。
尝试将其更改为非实体存档,我认为您应该会看到改进。
您可以尝试的第二件事是使用要添加的文件夹的文件列表(甚至掩码)对 WinRar 进行一次调用,而不是为每个文件夹单独调用它。
My guess is that your "c:\backup\projects.rar" archive is a solid archive, which means that it needs to be re-packed entirely each time you add something to it.
Try changing it to non-solid archive and I think you should see improvement.
The second thing you could try is to do a single call to WinRar with file-list (or even a mask) of what folders to add instead of calling it independently for each folder.