Ugly one-liner for gzip'ed gzip files

Had to rig up this one-liner to un-screw a situation were logrotate was configured to rotate and compress all files in a directory, including ones that had already been rotated and compressed; this sort of configuration lead to gzip'ed gzip files like this:

error_log-20141109.gz-20141111.gz-20141113.gz-20141115.gz-20141117.gz-20141119.gz-20141121.gz-20141123.gz-20141125.gz-20141127.gz-20141129.gz-20141201.gz-20141203.gz-20141205.gz-20141207.gz-20141209.gz-20141211.gz-20141213.gz-20141215.gz

The one-liner I put together to loop through and gunzip the many gzip'ed layers is:

for i in $(ls *.gz*); do loops=$(echo $i | awk 'END{print _}{_+=NF-3}' FS=".gz"); filename=$(echo $i | cut -d '-' -f 1,2); zcat $i > $filename; for a in $(seq $loops); do gunzip -c $filename > $filename-tmp; mv -f $filename-tmp $filename; done; rm -f $i; done

Very ugly but you do end up with all the files in your directory named and working the way they should.