The command unzip
has its own option unzip -Z1 zipfile.zip
to show the actual compressed filename within zipped file which is taking zipinfo's
option -1
as it's zipinfo -1 zipfile.zip
. so you could simply do as below and there is no need to create a temp directory and mv
will done in place in current directory.
for z in *.zip; do unzip "$z"; mv "$(unzip -Z1 $z)""${z%%.*}.txt";done