Skip to content

Instantly share code, notes, and snippets.

@nickferrando
Created August 24, 2023 01:23
Show Gist options
  • Save nickferrando/1cd6a15b89aa2640ee1ac5d3fc94ae29 to your computer and use it in GitHub Desktop.
Save nickferrando/1cd6a15b89aa2640ee1ac5d3fc94ae29 to your computer and use it in GitHub Desktop.
BASH Automation for FFmpeg processing, with Multiple Files Input and Separate Directories Output
#!/bin/bash
#This script will process each file in a given input directory
#and will create a corresponding output folder for each processed file.
# Input and output directories
input_dir="/your/input/directory"
output_dir="output_folder"
# Create the output directory if it doesn't exist
mkdir -p "$output_dir"
# Loop through each file in the input directory
for input_file in "$input_dir"/*; do
# Check if the item is a file (not a directory)
if [ -f "$input_file" ]; then
# Extract the filename without extension
filename=$(basename -- "$input_file")
filename_no_extension="${filename%.*}"
# Create a directory for this file's output
file_output_dir="$output_dir/$filename_no_extension"
mkdir -p "$file_output_dir"
# Your FFmpeg command here
ffmpeg -i "$input_file" -c:v libx265 "$file_output_dir/output.mp4"
echo "Processed: $input_file"
fi
done
echo "All files processed!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment