Fail to unzip .gz file using 7zip in Matlab

4 visualizaciones (últimos 30 días)
MM
MM el 1 de Nov. de 2022
Comentada: Star Strider el 1 de Nov. de 2022
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

Respuestas (1)

Star Strider
Star Strider el 1 de Nov. de 2022
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 comentarios
MM
MM el 1 de Nov. de 2022
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 el 1 de Nov. de 2022
My pleasure!
That would be difficult, since I don’t know how you set up your system. I’m also not familiar with 7zip.

Iniciar sesión para comentar.

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by