2

I have downloaded over 7000 ebooks from Project Gutenburg, but I have an issue. Each book has been placed in its own zip file, and each zip file has been given its own folder. My problem is that I do not want to have to go through each file and unzip them and put the ebooks in one place manually. If I can get the zip files in one place, it will be an easy job to unpack all of them with one command.

So, how do I get my files into one folder, instead of in their own subfolders?

3 Answers 3

4

Assuming that all the directories that contain the zip files have a common parent, you could use find to find all of the zip files then execute unzip on those files specifying the directory to extract the files to:

find /path/under/zip/folders -name "*.zip" -exec unzip {} -d /target/path \;
0

The wildcards approach can quickly get messy if there is more than a single level of nested folders...

I usually perform similar tasks (and most of other file operations) using Midnight Commander. Install it using

sudo apt-get install mc

Then just start it by typing 'mc', navigate to the folder your ebooks are in, hit Esc, then Ctrl-?, enter search criteria, in the result window hit [Panelize]. Now you can select all your zips by pressing * and copy/move them to the directory in another pane by hitting F5 or F6

-1

Do you have experience using wildcards? you could do something like

mv common_part_of_folder_name*/*.zip .

where the asterisk symbol basically means "anything". If you only have the gutenberg in your directory, you can just run

mv ./*/*.zip .

to get all the zip files into your current directory. If it's much more complex than that, a Perl or shell script might be the way to go.

1
  • The OP is not trying to copy the .zip files, but trying to extract them. Therefore, the correct command would involve wildcards and an archive program.
    – nanofarad
    Aug 3, 2012 at 13:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .