How to create a compressed archive for each folder in current directory
The following command will create a compressed tar archive for each folder found in the current directory.
It will use the LZMA/LZMA2 compression algorithms and it supports Unix-like file system metadata as well.
It will reuse the name of the folder for the archive as well and it will append the current date to the name.
find . -maxdepth 1 -mindepth 1 -type d -exec tar cJf "{}.`date +%F`.tar.xz" '{}' \;
The parameters we used for the find command are the following:
-maxdepth levelsDescend at most levels (a non-negative integer) levels of directories below the command line arguments.-maxdepth 0means only apply the tests and actions to the command line arguments.-mindepth levelsDo not apply any tests or actions at levels less than levels (a non-negative integer).-mindepth 1means process all files except the command line arguments.-type dMatch directories (folders) only
The parameters we used for the tar command are the following:
-ccreate a new archive-Jfilter the archive throughxz(compress the archive using thexzlossless compression program)-ffile use archive named file


