
| This forum is proudly powered by Scientific Linux 6 | SL website Download SL Help Search Members |
| Welcome Guest ( Log In | Register ) | Resend Validation Email |
![]() ![]() ![]() |
| pieniValkoinenHattu |
Posted: Apr 25 2012, 03:13 PM
|
|
![]() SLF Junior ![]() ![]() Group: Members Posts: 25 Member No.: 1452 Joined: 10-April 12 |
Hello,
I would like to know how to make a script to compress all the directories contained in a parent directory. To be clear I would like a way to do something like that: for directory from firstDirectory to lastDirectory do zip directory //the name of the zip should be the same as the directory end Thank you. |
|
| log69 |
Posted: Apr 25 2012, 03:47 PM
|
|||||||||
![]() SLF Member ![]() ![]() ![]() Group: Members Posts: 98 Member No.: 1325 Joined: 24-February 12 |
Not exactly entirely clear what you want.
To compress a dir recursively:
To compress all dirs separately in a parent dir:
or
My script looks like this (lbzip2 uses all CPU cores):
|
|||||||||
| AndrewSerk |
Posted: Apr 25 2012, 03:56 PM
|
|
![]() SLF Moderator ![]() ![]() ![]() ![]() ![]() ![]() Group: Moderators Posts: 524 Member No.: 54 Joined: 14-April 11 |
Moved from "How-to's / manuals / instructional manuals" to "Software and applications" as "How-to's / manuals / instructional manuals" if not for questions.
This post has been edited by AndrewSerk: Apr 25 2012, 03:57 PM |
|
| pieniValkoinenHattu |
Posted: Apr 25 2012, 04:05 PM
|
|||
![]() SLF Junior ![]() ![]() Group: Members Posts: 25 Member No.: 1452 Joined: 10-April 12 |
Thank you very much for answering however I don't know how to use what you wrote.
To be more precise I would like some kind of loop that compress each directory contained in a directory for exemple:
I am in the folder Family and I want to have one zip file for each directory it contains ( Father.zip, Mother.zip etc...) |
|||
| log69 |
Posted: Apr 26 2012, 07:52 AM
|
|||||
![]() SLF Member ![]() ![]() ![]() Group: Members Posts: 98 Member No.: 1325 Joined: 24-February 12 |
So you go with the command starting with the find command. Stand in your Family directory, and run it. |
|||||
| pieniValkoinenHattu |
Posted: Apr 26 2012, 09:42 AM
|
|||
![]() SLF Junior ![]() ![]() Group: Members Posts: 25 Member No.: 1452 Joined: 10-April 12 |
Sorry for being such a noob but it does not work:
I don't know what should I put instead of MYDIR, (I replaced the PARENTDIR by ../Family/* because other way it didn't work at all: not found directory ) |
|||
| log69 |
Posted: Apr 26 2012, 11:56 AM
|
|||||||
![]() SLF Member ![]() ![]() ![]() Group: Members Posts: 98 Member No.: 1325 Joined: 24-February 12 |
No problem, I said it incorrectly. Stay inside your Family dir, and run it with "find . -type d ...." with an extra options like this:
I tested it and it seems to be working just fine. |
|||||||
| pieniValkoinenHattu |
Posted: Apr 26 2012, 02:33 PM
|
|
![]() SLF Junior ![]() ![]() Group: Members Posts: 25 Member No.: 1452 Joined: 10-April 12 |
Thank you so much, this is awesome !
Could you explain me the line ? I would like to be able to make script like this one on my own. Thanks again ! |
|
| log69 |
Posted: Apr 26 2012, 03:11 PM
|
|||||||||
![]() SLF Member ![]() ![]() ![]() Group: Members Posts: 98 Member No.: 1325 Joined: 24-February 12 |
man find man sort man tail besides, try the script in parts, like:
etc. |
|||||||||
![]() |
![]() ![]() ![]() |