Site icon Bytefreaks.net

How to create a compressed archive for each folder in current directory

Advertisements

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:

The parameters we used for the tar command are the following:

This post is also available in: Greek

Exit mobile version