Bashスクリプトを使用してOneDriveの破損したzipを修復する方法

Bashスクリプトを使用してOneDriveの破損したzipを修復する方法

現在onedriveで作成されたzipファイルは、ほとんどのソフトウェアによって破損しています。

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

ここでわかるように、解決策は16進エディタを使用することです。大量のファイルが多いので、bashスクリプトソリューションが欲しい...可能ですか?

以下は無料で利用できるテストファイルです。

https://zenodo.org/record/3715394

ベストアンサー1

質問リンクに記載されている質問は、Microsoft OneDriveは大きくて破損したZIPファイルをエクスポートしますか?Total Number of Disks、OneDriveで作成された4Gigより大きいzipファイルにZIP64に無効なフィールドがある問題を示しますEnd Central Directory Locator。このフィールドの値は1でなければなりませんが、OneDrive(Windowsからzipに送信)はこれを0に設定します。これにより、標準の解凍ユーティリティを使用してこれらのファイルを処理することが困難または不可能になります。

これらのファイルのいずれかに対して実行すると、unzip次の出力が生成されます。

$ 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)

元の質問へのリンクは、16進ファイルエディタを使用して問題を手動で解決する方法を示しています。または以下を参照してください。OneDrive-Zipの回復これらのOneDrive zipファイルを修復するスクリプトです。実行する操作は、値が0に誤って設定されている場合に値を1に設定するだけです。

使い方は

fix-onedrive-zip file1.zip 

この場合

$./fix-onedrive-zip onedrive-zip-test-zeros.zip 

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

zipファイルを読み取ることができることを確認してください。

$ 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

おすすめ記事