Decompressing *.7Z Files with MATLAB

65 ビュー (過去 30 日間)
Matlab2010
Matlab2010 2014 年 10 月 28 日
コメント済み: Walter Roberson 2022 年 6 月 13 日
I have a 7z file. I wish to decompress it using Matlab. How can I do this? The inbuilt matlab functions dont support it.
I have tried,
[status,result] = system(['"C:\Program Files\WinRAR\UnRAR.exe" e ' E:\myFile.7z ' >null']);
however this fails as it gives
result =
UNRAR 5.11 freeware Copyright (c) 1993-2014 Alexander Roshal
E:\myFile.7z is not RAR archive
No files to extract
On closer inspection unrar.exe is not the same as winrar (which can do 7z). Hence i download 7-zip
[status,result] = system(['"C:\Program Files\7-Zip\7z.exe" e ' E:\myFile.7z]);
result =
7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Processing archive: E:\myFile.7z
Error: Can not open file as archive
any ideas?
thanks

採用された回答

Matlab2010
Matlab2010 2014 年 10 月 29 日
編集済み: Matlab2010 2014 年 11 月 22 日
solved:
[status,result] = system(['"C:\Program Files\7za920\7za.exe" -y x ' '"' filename{f} '"' ' -o' '"' outputDir '"']);
Also, just in case anyone finds it useful, compressing a file with winrar is done by:
[status,result] = system(['"C:\Program Files\WinRAR\Rar.exe" a ' 'C:\Users\user\Desktop\8736_test.rar ' ' C:\Users\user\Desktop\8736.mat' ' >null']);
  2 件のコメント
sunil kumar
sunil kumar 2019 年 5 月 7 日
How to extract .bz2 files in matlab
Could somebody help?
Walter Roberson
Walter Roberson 2019 年 5 月 7 日
system() out to the appropriate bzip2 or bunzip program with the appropriate options
It appears that some versions of gzip can handle .tar.bz2 files when given appropriate options.

サインインしてコメントする。

その他の回答 (1 件)

Jake August
Jake August 2016 年 4 月 19 日
This was very helpful. Someone else looking might find this useful.
% for 7zip 15.14 x64
file7z = 'D:\my.7z';
% rest of code
[dir7z,~,~] = fileparts( file7z );
dir7z = ['"' dir7z '"'];
file7z = ['"' file7z '"'];
[status,cmdout] = system( ['"C:\Program Files\7-Zip\7z.exe" x -o',dir7z,' ',file7z] );
  3 件のコメント
Verena Schwachmeyer
Verena Schwachmeyer 2022 年 6 月 13 日
Hi Jake August,
thank you. Your solution works for me - but only if I run it once. When this operation is part of an iteration, Matlab freezes during the second loop. Do you have an idea why that is and how to fix it?
-Verena
Walter Roberson
Walter Roberson 2022 年 6 月 13 日
Perhaps using .NET Systems.Diagnostic.Process() to start the process instead of system()

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePerformance and Memory についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by