1

I am using Manjaro Gnu/Linux and have a problem. I have a directory named files, and under this directory, I have around 650 zip files, with names such as: file1.zip, file2.zip, file3.zip,...

I want to write a command/script to automatically unzip all of the '.zip' files into a sub-directory, having the same name as the zip file. For example, 'file1.zip' file's contents should be unzipped into a sub-directory called 'file1', 'file2.zip' file's contents should be unzipped into a sub-directory called 'file2' and so forth.

1 Answer 1

4

Just use a simple for loop with a glob expression iterating over your input zip files and unzip them with extension removed

for file in *.zip; do
    [ -f "$file" ] || continue
    unzip "$file" -d "${file%%.zip}"
done

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.