Score:0

extract many zip files but set different destination directories following the content file extensions with unzip cmd

pn flag

I have many .zip files, each file contains many different file with different extensions, e.g: .c, .py, .java and .cpp etc.

I am only interesting to extract all file with .py or .java from these zip files. I am using this command unzip -d myDestinationFolder/ "Na*.zip" "*.py" "*.java"

It unzips my wanted files with specific extensions to the directory myDestinationDirectory.

Is there a way to mkdir automatically following the wanted file types then unzips them to the corresponding directory?

So all .py files are extracted to a directory called py, .java to another directory called java etc.

Sadaharu Wakisaka avatar
pl flag
`unzip archive-name "*.py" -d dist-name`
Khaled avatar
pn flag
I wann a to extract not only one filetype but many at once
Sadaharu Wakisaka avatar
pl flag
Unix/Linux philosophy is to do the simple thing without mistakes. You can do this which you prefer. #1 extract everything sort after, #2 extract only sorted files. `unzip archive-name "*.py" -d dist-name1 && unzip archive-name "*.java" -d dist-name2` I like this simplicity. You can also do #1 method, `find -name ...` but I assume they are the same thing.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.