Yes, it should be. However, the syntax you used (without
in) does a loop over the arguments of the script. To specify a list of directories you have to do something like this
Code:
for folder in */
do
echo rar a -r "${folder%/}.rar" "$folder"
done
this loops over all the folders in the current directory. The parameter substitution
${folder%/} serves to strip out the "/" at the end of the folder name.
I put a leading echo to the rar command for testing purpose. Visualize the commands which will be executed and when you're satisfied with the results, strip out the echo.
Just a note regarding what I previously stated. Actually the rar utility preserves the directory structure inside the archive. I had only to extract by
unrar x instead of
unrar e.