使用 7-zip 批处理:先将最小文件压缩到最大文件
我有一个 .bat 文件,它运行 7-zip 来压缩目录中的所有文件。文件大小从 1mb 到 500mb 不等,共有 10 个文件。每 15 分钟,计划的备份程序就会覆盖 10 个文件中的 5 个。这 5 个文件通常是最小的且压缩速度最快,但 7-zip 首先从最大的文件开始,因此在 15 分钟内丢失了这 5 个文件。如何让 7-zip 首先从最小的文件开始。任何帮助将不胜感激。
c:
cd "\Program Files\7-Zip"
7z a C:\WEBDATA C:\FILE1.BAK C:\FILE2.BAK C:\FILE3 C:\FILE4 C:\FILE5 etc...
I have a .bat file that runs 7-zip to compress all files in a directory. The files range in size from 1mb to 500mb and there are 10 files. Every 15 mins a scheduled backup program overwrites 5 of the 10 files. Those 5 files are usually the smallest and the quickest to compress, but 7-zip starts with the largest file first thus missing the 5 files within the 15 minutes. How do I get 7-zip to start with the smallest file first. Any help would be much appreciated.
c:
cd "\Program Files\7-Zip"
7z a C:\WEBDATA C:\FILE1.BAK C:\FILE2.BAK C:\FILE3 C:\FILE4 C:\FILE5 etc...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果所有文件都位于同一目录中,则可以使用 dir 命令的排序功能一次将一个文件添加到存档中。
例如,如果要备份的文件位于名为“files”的子目录中:
根据您的描述,这应该足够了,但如果文件位于不同的位置,您可能需要更高级。我自己还没有尝试过,但我希望您可以循环遍历目录列表,将每个大小/文件名写入临时文件,然后对该文件使用
sort
命令。If all of the files are in the same directory, you can use the sort feature of the
dir
command to add files to the archive one at a time.For example, if the files to back up are in a subdirectory called 'files':
Based on your description this should be sufficient, but if the files are in various locations you may need to get fancier. I haven't tried it myself, but I would expect you could loop through a list of directories, writing each size / filename to a temporary file, then using the
sort
command on that file.