First of all, please use ***
[code][/code]*** tags around your code and data, to preserve the original formatting and to improve readability. Do
not use quote tags, bolding, colors, "start/end" lines, or other creative techniques. Thanks.
I'm not completely sure I understand what you need. You want to unzip the contents of the archive, replace a string in each name, then re-zip it?
What is the exact problem you're having with the script you posted? I can't understand half of what it's trying to do. What's all that stuff with awk, 3.txt,
expr (a useless command since modern shells have built-ins that can do everything it does), and all that?
parsing ls is not recommended in any case, so I doubt it's doing any good.
Couldn't you just do something like this?
Code:
#!/bin/bash
zippath=/location/of/zipfiles
outpath=/path/to/outputdir
tmpdir=/whatever/you/want
[[ -d $tempdir ]] && cd "$tempdir" || { echo 'No tempdir available' ; exit 1 ;}
for zipfile in "$zippath/"*.zip; do
unzip "$zipfile"
for fname in *; do
mv "$fname" "${fname/1139/1200}"
done
outzip=$outpath/${zipfile##*/}
outzip=${outzip/1139/1200}
zip "$outzip" *
rm -f *
done
exit 0
Please explain if you need something else.