Compress all the folders in a directory with rar on Linux




To compress all the folders in a directory on the current path (only the folders)
Open a bash terminal , move to the wanted path with cd , then type:


for dir in */
do
 base=$(basename "$dir")
 rar a "${base}" "$dir"
 echo $base >> "log"
 rm -rf "$base"
done

Press enter.
Each folder will be replaced with a rar file with the same name and the same files the folders had.
Try this on some test folders before using it on the final folders..

        






Comments:

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.