From d5e18eed1555fdcd03c3d7d68f22d59e3cecbb61 Mon Sep 17 00:00:00 2001 From: Steven Baltakatei Sandoval Date: Mon, 11 Mar 2024 02:04:14 +0000 Subject: [PATCH 1/1] fix(unitproc/bk_export_audio.sh):Do not overwrite output files --- unitproc/bk_export_audio.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/unitproc/bk_export_audio.sh b/unitproc/bk_export_audio.sh index 1100811..bbf3f3d 100755 --- a/unitproc/bk_export_audio.sh +++ b/unitproc/bk_export_audio.sh @@ -1,7 +1,7 @@ #!/bin/bash # Desc: Extracts audio from video files # Usage: bk_export_audio.sh [input_dir] ([output_dir]) -# Version: 0.1.0 +# Version: 0.1.1 # Depends: bash 5.1.16, GNU Coreutils (8.32) # Plumbing @@ -226,14 +226,18 @@ extract_audio_file() { # arg2: desired output file extension # arg3: output dir path # Output: audio file at path [arg3]/[arg1].[arg2] - local file_in file_in_ext dir_out file_in_basename; + local file_in file_in_ext dir_out file_in_basename path_out; file_in="$1"; file_in_ext="$2"; dir_out="$3"; + file_in_basename="$(basename "$file_in")"; + path_out="$dir_out"/"$file_in_basename"."$file_in_ext"; + + # Skip if output file already exists. + if [[ -f "$path_out" ]]; then return 1; fi; # Extract audio file - file_in_basename="$(basename "$file_in")"; - ffmpeg -i "$file_in" -vn -acodec copy "$dir_out"/"$file_in_basename"."$file_in_ext"; + ffmpeg -i "$file_in" -vn -acodec copy "$path_out"; } # Create audio file from video file count_jobs() { # Desc: Count and return total number of jobs -- 2.30.2