How to extract and join files in Matlab - matlab

I have three files 1.zip, 1.z01 1.z02. I would like to extract and join them into a file.
In Ubuntu command line I'm using zip -FF name.zip --out name_joinde.zip
I would like to do this in Matlab, but with the zip command I'm getting an Invalid zip file error. How can I joint this files?

You cannot do it in one shot. But it is easy to do systematically using the zip and unzip commands:
%% Unzip files into "tempdir" directory (will create the directory if needed)
unzip('MyFruits.zip', 'tempdir')
unzip('MyColors.zip', 'tempdir')
%% Zip all files in "tempdir" directory into Joined.zip
zip('Joined.zip', '*.*', 'tempdir')
%% Delete the "tempdir" directory and all of its subdirectories
rmdir('tempdir', 's')

Try using the
unzip(..)
command first, and then
zip(..)

How about just using ! or system to call the Ubuntu command directly from within MATLAB?

Related

How to insert a folder into .tar file in MATLAB by using UNIX commands?

I have many folder like data_1,data_2, data_3 etc, that will be generated during program running. I want to copy these folders into .tar file named full_data.tar in a specified folder.
How can I insert folders named data_1,data_2, data_3 etc into full_data.tar in MATLAB by using UNIX commands?
As #kedarps already proposed I would also use the command line. The matlab command to execute command line arguments is:
status = system(command)
It is documented under this link:
system documentation
So if I take the unixcommand from #kedarps this should work:
system('tar -cvf full_tar.tar data_1 data_2 data_3')
I hope this helps

7zip / winrar command to extract a folder with path intact to specific folder but excluding parent source path

example
There is a file "sample.rar".
Folder structure is: "rising\dawn\ and here there are many (folders1, folders2 and file1, file2)" in this archive.
i have used following command
7z.exe x "sample.rar" "rising\dawn\*" -oi:\delete
The result is:
all files and folders in "rising\dawn\" are extracted to "i:\delete" folder but the empty parent folders "rising\dawn\" are also created in destination folder.
e.g. destination looks:
i:\delete\rising\dawn\folder1\file1.bmp
i:\delete\rising\dawn\folder2\subfolder
i:\delete\rising\dawn\file1.txt
i:\delete\rising\dawn\file2.txt
i don't want "rising\dawn\" empty folders to be created but the folder structure there onwards must be as is in the archive.
i want the result:
i:\delete\folder1\file1.bmp
i:\delete\folder2\subfolder
i:\delete\file1.txt
i:\delete\file2.txt
at last i found a way out solution. thanks to the winrar support. i have accepted it as an answer below.
if you find the question useful don't forget to click the up-vote button.
Finally this gave me the result.
Thanks to winrar support.
rar x -ep1 sample.rar rising\dawn\* d:\e\delete\
i have tried other answers given here, this is the only correct answer.
don't forget to upvote.
You can extract the archive normally and
1) move the lower level folder/files to where you would like it, then
2) remove the extra top level archive folders.
Code to do so will depend on the exact task.
Using e command instead of x and add -r option works well.
Like this:
7z.exe e -r "sample.rar" "rising\dawn\*" -oi:\delete
My executable version is "7-Zip [64] 9.20 2010-11-18",
And the platform is Windows 8.1.
This command line eliminates unnecessary parent folders and preserves the hierarchy of folders.
You need to use the e command rather than the x command:
7z.exe e "sample.rar" "scholar\update\*" -oi:\delete
Using e instead of x means 7zip will extract all matching files into the same folder (as specified via the -so switch, or the current directory if this isn't specified) rather than preserving the folder structure from inside the archive.

Linux zip command - adding date elements to file name

occasionally I run a backup of my phpbb forum files from the Shell command line:
zip -r forum_backup ~/public_html/forum/*
I'd like to add date elements to the file name, so that the zip file created is automatically formed as
forum_backup_05182013.zip
any other similar current date format would also be acceptable
now=$(date +"%m%d%Y")
zip -r forum_backup_$now ~/public_html/forum/
Without defining a variable first you can do it in one line with
zip -r "forum_backup_$(date +"%Y-%m-%d").zip" filelist
As taken from here
the following shell command, change the format as you want
FORMAT="%Y%m%d"
_DATE=$(date +"$FORMAT" )
zip -r "forum_bakcup_${_DATE}" ~/public_html/forum/*

Compress a folder using tar in MATLAB

I try compress a folder in MATLAB using tar. I want to assign the current date as the name of the archive file. When I try
tar 'datestr(now)' FooFolder
Nothing happens. With
tar datestr(now) FooFolder
the name of the archive file is datestr(now).tar as expected. What is the solution?
The documentation is quite clear, use the function syntax:
tar(tarfilename,files)
Example:
tar(datestr(now),'FooFolder')

How to partially extract a folder from a 7z file using powershell

I'm trying to automate the install of my platform. I've made a script for compressing the build of the deployables to a 7zip file.
Now i need to uncompress partially some folders to a specific destination.
Package
-app1
--folder11
---folder111
--folder12
-app2
--folder21
--folder22
...
I need to create a powershell script to extract the content of 'app1' to a destination folder.
I've been trying to use the following command but the result is not the as i expected.
I've been receiving the full path and not the content from folder11 recursivelly.
Set-Alias zip $ZipCommand
zip x $FilePath app1\folder11 -oc:DeployableFolder -r
Any ideas? Suggestions?
Thanks.
I tried and had no issue.
set-alias zip "c:\Program Files\outils\7-Zip\7z.exe"
zip x program.7z python-core-2.6.1\lib -oc:\data
I eventually got a c:\data\python-core-2.6.1 which only contains the lib folder with all its subfolders & files.
The only difference I see is the backslash \ in the output path.
HTH