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.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>