Fail to unzip .gz file using 7zip in Matlab
4 次查看(过去 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
0 个评论
回答(1 个)
Star Strider
2022-11-1
2 个评论
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 Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!