Unzipping lots of files in subdirectories to the current directory

By on

Have you ever had a bunch of subdirectories each filled with only one zip file? Or have you ever had a task that needed to be done in the same way?

Well here's a handy little line of code that will help you on your way!

find -name '*.zip' | xargs -n1 echo unzip

This doesn't actually do anything yet, it searches for .zip files in every subdirectory relative to the one you're currently in and then echoes what it'll do to those files once you remove the echo command So actually typing:

find -name '*.zip' | xargs -n1 unzip

Will perform the command. Another example, if you want to copy lots of files from the subdirectory of one map to another, you can do this:

find /home/user/map/ -name "*.txt" | xargs -i cp -v {} .

This will copy every .txt file under any directory, starting from /home/user/map/, to your current directory. (No matter where you are)

I love it, and it has saved me lots of time!

Comments

vssihqwv

01/01/1967

means wearing

I leave a leave a response each time I like a post on a blog or if I have something to contribute to the discussion. Usually it's a result of the fire communicated in the post I read. And on this post Unzipping lots of files in subdirectories to the current directory | Skerit.com | Speak of the devel. I was moved enough to drop a thought ;) I do have a couple of questions for you if it's okay. Is it just me or does it look like like some of the responses appear like they are written by brain dead individuals? :-P And, if you are writing on additional social sites, I'd like to keep up with everything fresh you have to post.

Would you make a list the complete urls of your public pages like your twitter feed, Facebook page or linkedin profile?

MuillNot

I thought I asked you to be here by nine o'clock. His name is on the tip of my tongue.

MuillNot

I'm really surprised that. As far as I am concerned, both the book and the movie are good.

Ilona.K.lNot

He was sick for a month, but now he is up and around. Oh hell!

Took F lTam

It stands to reason that he apologized.

Jelle De Loecker