Scripts

I use Linux, which means I have spent way too much time making bash scripts instead of solving my problems. Here are some of the fruits of my labor. These are all probably unoptomized and Stack Exchange would rip me to shreds but I'm literally just some guy ^_^

2 Februrary 2026

Merge video files

I handle a lot of video files, some of which need to megamorph into one video file. Requires ffmpeg (my beloved) and the PERL VERSION OF RENAME! Linux default comes with the linix-utils one which doesn't support regex because it hates me.


#!/bin/bash

# "Parts Directory" is the directory where all the videos to be combined are at. It will get EVERYTHING IN THAT FILE so BE CAREFUL!
# Output file name is what it sounds like. No need to put a file extension, it appends .mp4 automatically :thumbs_up:
read -p 'Parts Directory: ' dir
read -p 'Output File Name: ' output

#Remove ' from file names
perl-rename "s/\'/_/" "$HOME"/"$dir"/*.mp4

#List files in directory
ls -v "$HOME/$dir" > temp.txt

#Add "file '$HOME/DIRECTORY" to start
sed -i "s#^#file '"$HOME/$dir/#"" temp.txt

#Add ' to end
sed -i "s_\$_'_" temp.txt

#Concatenates videos files with ffmpeg
ffmpeg -safe 0 -f concat -i temp.txt -c copy "$output".mp4

rm temp.txt

2 February 2026
ffmpeg video