首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用bash脚本修复onedrive损坏的zip

如何使用bash脚本修复onedrive损坏的zip
EN

Unix & Linux用户
提问于 2020-05-30 10:49:52
回答 1查看 3.7K关注 0票数 8

目前,onedrive生成的压缩文件被破坏到大多数软件。

https://www.bitsgalore.org/2020/03/11/does-microsoft-onedrive-export-large-ZIP-files-that-are-corrupt

正如我们在这里看到的,解决方案是使用十六进制编辑器。因为我有很多大文件,所以我想要bash脚本solution...is吗?

这是一个免费的测试文件:

https://zenodo.org/record/3715394

EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2020-05-30 23:16:26

问题中的链接微软OneDrive是否导出损坏的大型ZIP文件?中提到的问题是OneDrive大于4Gig创建的文件在ZIP64 End Central Directory Locator中有一个无效的Total Number of Disks字段的问题。这个字段中的值应该是1,但是OneDrive (似乎是)将其设置为0。这使得使用标准解压缩实用程序处理这些文件变得困难/不可能。

对其中一个文件运行unzip会产生如下输出

代码语言:javascript
复制
$ unzip -l  onedrive-zip-test-zeros.zip
Archive:  onedrive-zip-test-zeros.zip
warning [onedrive-zip-test-zeros.zip]:  1073742329 extra bytes at beginning or within zipfile
  (attempting to process anyway)
error [onedrive-zip-test-zeros.zip]:  start of central directory not found;
  zipfile corrupt.
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)

原始问题中的链接显示了如何使用十六进制文件编辑器手动修复该问题。或者,请参阅Fix-OneDrive-Zip以获得修复这些OneDrive压缩文件的脚本。如果值被错误地设置为0,那么它所做的就是将值设置为1。

用法是

代码语言:javascript
复制
fix-onedrive-zip file1.zip 

在这种情况下

代码语言:javascript
复制
$./fix-onedrive-zip onedrive-zip-test-zeros.zip 

Checking 'onedrive-zip-test-zeros.zip'
Updated 'onedrive-zip-test-zeros.zip'

并且可以读取查看zip文件。

代码语言:javascript
复制
$ unzip -l onedrive-zip-test-zeros.zip 
Archive:  onedrive-zip-test-zeros.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
1073741824  2020-03-18 14:48   onedrive-zip-test-zeros/file01.dat
1073741824  2020-03-18 14:51   onedrive-zip-test-zeros/file02.dat
1073741824  2020-03-18 14:54   onedrive-zip-test-zeros/file03.dat
1073741824  2020-03-18 14:57   onedrive-zip-test-zeros/file04.dat
1073741824  2020-03-18 15:01   onedrive-zip-test-zeros/file05.dat
---------                     -------
5368709120                     5 files
票数 13
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/589925

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档