Hi Arunomi.
You could use the command 'find' to get both the files on the directory and the list of directories in it.
This will get the files:
Code:
find -maxdepth 1 - type f
and this the subdirectories:
Code:
find -maxdepth 1 -type d -not -name .
where:
'-maxdepth 1' means to not descent looking on the subdirectories.
'-type f' means files.
'-type d' means directories.
''-not -name .' means do not include the directory itself (represented by .).
You can execute a command every time 'find' finds a directory by using the exec option:
Code:
find -maxdepth 1 -type d -not -name . -exec zip -r '{}'.zip '{}' \;
where '{}' makes reference to the directory just found. For example when it finds the dir 'Music', it will run:
Code:
zip -r Music.zip Music
thus recursively scanning 'Music' and compress it into Muzic.zip
For the files you need a different approach. You don't want each file compress by it self, but all of them together in one zip.
You can also use the exec option but this time the command will be executed at the end using all files found as parameters:
Code:
find -maxdepth 1 -type f -exec zip localfiles.zip '{}' +
This time all files directly under the folder will be compress into 'localfiles.zip'.
I hope that helps, and tell us how it goes.
Regards.
BTW, you may need to install zip:
Code:
sudo apt-get install zip
Bookmarks