Extracting the base name of a file in Bash
I have a handy bash script that transcodes videos using Don Meton's video_transcoding tools. This script was written in a hurry and one limitation it had was that it re-transcoded any source file even if the output file already existed. The script looked like this: #!/usr/bin/env bash readonly source_dir="${1:-MKV}" readonly output_dir="${2:-MP4}" for file in "$source_dir"/*.mkv; do ./transcode.sh "$file" "$output_dir" done What it should do is only run transcode.sh if the output file doesn't exist, so… continue reading.