I am converting an entire folder of videos to MP4. The script works except that the new videos have “.mp4” attached twice to them. For example. ‘video.mp3’ would be ‘video.mp3.mp4’ after conversion. Below is the shell script. TIA
#!/bin/bash #Shell Script which converts all videos in a folder to MP4 for file in *.*; do if[ ${file: -4} != ".mp4"] #don't want to convert mp4 files ffmpeg -i "$file" "${file}".mp4 done
Advertisement
Answer
This will strip the last file extension: ${file%.*}
So you’d want ${file%.*}.mp4
Here is a good reference for string manipulation in bash: http://tldp.org/LDP/abs/html/string-manipulation.html