#! /bin/bash #looks for m4v extension and, if found, looks for file with the same name ending in mkv, and if found, deletes the mkv for NAME in `find "$1" -type d`/*; do echo "Processing: " "$NAME" filename=$(basename "$NAME") extension=${filename##*.} filename=${filename%.*} #echo "Extension is: " "$extension" #echo "Filename is: " "$filename" if [ "$extension" = "m4v" ]; then #echo "Inside if" echo "Filename is still: " "$filename" and combined it is "$filename"".mkv" echo "DELETING " find "$1" -name "$filename" -exec rm {} \; fi done ~