0

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.

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.