Skip to content

How to Create Tar Archives for Each Folder in a Directory

The following commands create tar archives folder by folder into their own tar — so each folder becomes folder.tar.

Compressed archive

Terminal window
find . -type d -maxdepth 1 -mindepth 1 -exec tar zcvf {}.tar.gz {} \;

Uncompressed archive

Terminal window
find . -type d -maxdepth 1 -mindepth 1 -exec tar cvf {}.tar {} \;