#!/bin/bash SAVEIFS=$IFS IFS=$(echo -en "\n\b") for f in *1.wmv do shortfile=${f::-5} echo "file '"$shortfile"1.wmv" > list.txt echo "file '"$shortfile"2.wmv" >> list.txt echo "file '"$shortfile"3.wmv" >> list.txt ffmpeg -f concat -safe 0 -i list.txt -c copy $shortfile.wmv rm list.txt done IFS=$SAVEIFS