Hello all.
I have a whole bunch of zip files that I would like to convert into individual gzip files.
Basically I want to unzip the zip file into a directory named the same as the zip file, but without the .zip
Then I want to individually gzip each file inside.
I need to have it in a sub directory since files inside the zip file can be named the same as in other zip files.
It is a bit difficult to explain so I will try to illustrate
Documents(Eng).zip
Document1.rtf
Document2.rtf
Documents(Ger).zip
Document1.rtf
Document2.rtf
Documents(Fre).zip
Document1.rtf
Document2.rtf
The part I'm having trouble with is the first step of unzipping into a folder named the same as the zip file.
I painfully did one of my directories with Zip files, one by one.
and then to gzip the files was easy,
In folder with all subfolders.
Code:
find -iname '*.rtf' -execdir gzip -9 {} \;
However I have 34 Directories with each containing some 600 zip files.
so as you can guess it is a pain to do it manually. :-)
I tried to make my script grab the file name and then use sed to strip the .zip, but I can't even get that to work.
To prevent any actual change I used just an echo to generate the output, but it get's messed up.
It correctly removes the .zip, but it cuts the filename on each space and special characters.
Code:
#!/bin/bash
for file in $( find -iname '*.zip')
do
output=`echo $file | sed 's/.zip//g'`
echo $output
done
exit 0
Any ideas why or maybe a better way of doing it?