Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-13-2005, 01:04 AM   #1
LQ Newbie
Registered: Apr 2005
Posts: 26

Rep: Reputation: 16
Unzip multiple zip files, each to separate folder

I have a set of zip files,,, and in a particular folder. I need to unzip each of these zip files to a separate folder as follows: ==> 123_1 ==> 123_2 ==> 123_3

My problem is, I need to do this whole thing using a *single* command, something like the 'Extract each file to separate folder' option present in WinZip.

Any suggestions?
Old 04-13-2005, 01:16 AM   #2
Senior Member
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
You'll want to do something like this (try this on test files -- I haven't got a box to test it on right now):
for file in `ls | grep 123`; do unzip $file -d `echo $file | cut -d . | grep 123`; done
Something like that... Don't know if that'll work or not...
Now we sit and wait for someone to pick apart my terrible scripting skills

Last edited by scuzzman; 04-13-2005 at 01:22 AM.
1 members found this post helpful.
Old 04-13-2005, 01:50 AM   #3
LQ Newbie
Registered: Apr 2005
Posts: 26

Original Poster
Rep: Reputation: 16
Brilliant! It worked. Just a small change had to be done.

for file in `ls 123_*.zip'; do unzip $file -d `echo $file | cut -d "." -f 1`; done
Thanks a lot!
1 members found this post helpful.
Old 03-21-2012, 08:41 AM   #4
LQ Newbie
Registered: Mar 2012
Posts: 1

Rep: Reputation: Disabled
minimalistic error in the previous post

Great! This just saved me a lot of time compared to figuring it out by myself. Thanks to the authors!
Although this response is a little late, those that come here from a web search might save another minute with this very tiny correction: There is one "'" instead of "`" in smart_sagittari's code. Here's what I used (for arbitrarily named zip files):

for file in `ls *.zip`; do unzip $file -d `echo $file | cut -d . -f 1`; done


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
unzip all .zip files in a directory tes15 Linux - Newbie 14 08-29-2014 11:46 AM
How to Unzip 2 Zip files through one single command sumitarun Linux - Newbie 2 03-23-2005 08:00 AM
How to unzip all the src files in linux src folder? raj_ice Linux - Newbie 1 10-15-2004 09:46 AM
Zip and Unzip concoran Linux - General 4 08-02-2002 07:12 PM
how do i unzip a .zip? lax2sman Linux - General 2 02-11-2002 05:17 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:53 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration