Results 1 to 7 of 7

Thread: [SOLVED] how to compress 10 folders to 10 archives by one command

  1. #1
    Join Date
    Oct 2007
    Location
    hk
    Beans
    707
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    [SOLVED] how to compress 10 folders to 10 archives by one command

    i need to compress each holder to an archive. it has nearly a hundred folders. how can i do this in a quickest way? i don't want to right click each --> "create archive.." that tooooo slow! thanks!
    Ubuntu 7.10 on P4 1.8G and PIII 933mHz

  2. #2
    Join Date
    Jun 2006
    Location
    Switzerland
    Beans
    Hidden!
    Distro
    Kubuntu Jaunty Jackalope (testing)

    Re: how to compress 10 folders to 10 archives by one command

    write a shell script that loops through each directory name and compresses it.

  3. #3
    Join Date
    Oct 2007
    Location
    hk
    Beans
    707
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: how to compress 10 folders to 10 archives by one command

    sorry i don't know how to write a script! noob.....
    Ubuntu 7.10 on P4 1.8G and PIII 933mHz

  4. #4
    Join Date
    Jan 2007
    Location
    $here ? $here : $there
    Beans
    3,717
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: how to compress 10 folders to 10 archives by one command

    Try:

    Code:
    find . -maxdepth 1 -type d ! -name "." -exec echo "'{}'" \; -exec tar cf '{}.tar' '{}' \;
    That will make a tar file for every directory in the directory it's run.
    Don't try to make something "fast" until you are able to quantify "slow".

  5. #5
    Join Date
    Oct 2007
    Location
    hk
    Beans
    707
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: how to compress 10 folders to 10 archives by one command

    if i want it to be .zip or .rar then should it be
    find . -maxdepth 1 -type d ! -name "." -exec echo "'{}'" \; -exec zip cf '{}.zip' '{}' \;
    Ubuntu 7.10 on P4 1.8G and PIII 933mHz

  6. #6
    Join Date
    Jan 2007
    Location
    $here ? $here : $there
    Beans
    3,717
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: how to compress 10 folders to 10 archives by one command

    I'm not familiar with the syntax of zip but, it looks like you understand the find command I posted so, you may want to check the man page for zip and figure out the exact syntax zip uses to create an archive:

    Code:
    man zip
    Don't try to make something "fast" until you are able to quantify "slow".

  7. #7
    Join Date
    Oct 2007
    Location
    hk
    Beans
    707
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: how to compress 10 folders to 10 archives by one command

    thanks. problem solved
    Ubuntu 7.10 on P4 1.8G and PIII 933mHz

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •