rendered paste body#!/usr/bin/env bashACTUALDIR=`pwd`for file in ./*.zipdo REMOVE=0 echo "Found file ${file}" RESULT=$(echo $(unzip -o "${file}") | sed -e 's/.*inflating:\s\(.*\)/\1/') echo "Got file ${RESULT}" EPISODE=$(echo "$RESULT" | sed -e 's/.*\([1-9]\+x[0-9]\{1,2\}\).*/\1/') echo "Searching for episode ${EPISODE}..." for avifile in ./*.avi do MATCH=$(echo $avifile|sed -e 's/.*S0\?\([1-9]\+\)E\([0-9]\{1,2\}\).*/\1x\2/') if [[ "${EPISODE}" == "${MATCH}" ]] then echo "Found ${avifile}" AVINAME=`echo "$avifile" | sed -e 's/\(.*\)\.avi/\1/'` echo "Renaming ${RESULT} to ${AVINAME}.srt." mv --force "./${RESULT}" "${AVINAME}.srt" REMOVE=1 fi done [[ $REMOVE -eq 1 ]]; echo "Removing old zipfile"; rm -f "${file}"done