compress folder in rar
I wanted to compress each folder in a directory rar or zip, and the files would have to have the name of your folders
|
To create a zip archive the command is
Code:
zip -R directory.zip directory/* Code:
rar a -r directory.rar directory/* |
I wanted to do this is automated, because I have about 7000 folders
would be something like? Code:
for folder; do rar a -r "$folder.rar" "$folder"; done |
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 */ 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. |
Perfect, worked certinho, thank you very much.
Whenever I have some doubts in these exchanges of office files to folders. |
Attention to echo command, maybe don't work if it is present in CentosOS
Code:
for folder in */; do rar a -m0 -r "${folder%/}.rar" "$folder"; done Code:
${folder%/}.rar Code:
${folder%/}.zip source: http://stackoverflow.com/questions/2...-centos-ubuntu |
All times are GMT -5. The time now is 09:31 PM. |