File path like this: path/path/path/File name 2.3.pdf.zip
What am I doing wrong:
# unzip files back to normal
# and remove zip files
for f in `find "$1" -type f -iname "*.zip"`; do
dir=`dirname "$f"`
unzip -o "$f" -d "$dir"
rm -f "$f"
done
Error message: unzip: cannot find or open file, file.zip, or file.ZIP
Using UnZip 5.52 Red Hat Enterprise Linux Server release 5.10 (Tikanga)
I think your loop is splitting up the output of find based on the spaces. You may want to do something to read one line at a time, like this
find "$1" -type f -iname "*.zip" | while read f
do
dir=`dirname "$f"`
unzip -o "$f" -d "$dir"
rm -f "$f"
done
Or, alternatively, you could set IFS:
IFS='\n'
for f in `find "$1" -type f -iname "*.zip"`; do
dir=`dirname "$f"`
unzip -o "$f" -d "$dir"
rm -f "$f"
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With