My directory looks like this
./Dir1/Some file.zip
./Dir2/Some other file.zip
./UnzipFiles.sh
I want to loop through each directory in ./
and unzip each one's zip file.
UnzipFiles.sh
looks like this:
#!/bin/bash
for i in ./*/*.zip
do
cd "$i";
unzip "$i";
done
But that unzips everything into ./
. I want each .zip file's contents to unzip into the directory containing it.
How do I do this in bash?
I was cd
-ing into each .zip
file itself. Instead, I needed to do this:
#!/bin/bash
for i in ./*/
do
cd "$i";
unzip *.zip;
cd ../;
done