I have many zip files (think 100-150) in a folder. Each zip file has multiple files with different file extensions. I know how to write a bash for loop to unzip all the contents of these files.
What I want to do is this.... Use 7z (or some other) to unzip each zip file and given the contents of that zip file the same file name as the zip file.
This is what I have currently.
#!/bin/bash
for i in *.zip;
do
echo $i #For debugging purpose
7z x $i &
done
Edit 2:
#!/bin/bash
for i in *.zip;
do
fbname=$(basename "$i" .zip);
fem_fileName=$(unzip -l $i | grep .fem | awk '{print $4}')
echo $fbname
echo $fem_fileName
$unzip $i
7z e $i *.fem -y
#echo $fbname
#echo $fem_fileName
mv $fem_fileName $fbname
done
The newest issue is: what if the zip file I am operating on has multiple sub-directories? How do I have 7z or other utility recursively check for "folder in folder in zip file"?
Zip_file:
|----Folder_1
|------------Folder_2
|--------------------Contents_to_extract
Contents_to_extract > change file name to > zip_file