Fail to unzip .gz file using 7zip in Matlab

6 次查看(过去 30 天)
Hello,
I have a folder that has multiple gz files and I'd like to unzip the selected file from the folder to unzip. I first select the file and save it under gz_full_path. I havea destination folder called session_folder_path where the extracted file needs to be saved.
The 7 zip exe is already in the path.
When I run the code below, it returns an error 'COMMAND must be a string scalar or character vector'.
When I run the alternate version to extract using 7zip, it retrns an error 'Incorrect command line'.
Any pointers on what is wrong would help. it was working couple of hours ago but it is failing to run now. Unsure why
[gz_file, gz_path] = uigetfile('*.gz', 'Select the session output file', session_folder_path);
gz_full_path = strcat(gz_path, gz_file);
[status,output] = system(['"C:\Program Files\7-zip\7za920\7za.exe" -y x ' '"' gz_full_path '"' ' -o' '"' session_folder_path '"']);
if status
error("There was an error running your command: %s", output);
return;
end
%%%
%Alternate version
unzip_cmd = "7za e" + gz_full_path + " -o" + session_folder_path + "\files -y";
[status,output] = system(unzip_cmd);
if status
error("There was an error running your command: %s", output);
return;
end

回答(1 个)

Star Strider
Star Strider 2022-11-1
I’m not certain what you want to do.
MATLAB has the built-in unzip and gunzip functions that I use frequently, especially here with the online Run feature.
You should have them, since they both were introduced prior to the R2006a release.
.
  2 个评论
MM
MM 2022-11-1
Thanks for your answer. I'll give it unzip a try as well.
If I wish to continue to use 7zip because of the file size could you help understand the source of this error?
Star Strider
Star Strider 2022-11-1
My pleasure!
That would be difficult, since I don’t know how you set up your system. I’m also not familiar with 7zip.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by