Created
March 2, 2026 18:08
-
-
Save ErykDarnowski/2211cc606065504fcc127801f60c244b to your computer and use it in GitHub Desktop.
Quick & dirty shell script for automatically stripping audio from all mp4 files in a path (requiers ffmpeg to work).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # **A quick & dirty script for removing audio from mp4 files in a given dir.** | |
| ## Check if path given as arg: | |
| if [ $# -eq 0 ]; then | |
| echo "ERR! No path supplied"; exit 1; | |
| fi | |
| ## Check if give path exists: | |
| if [ ! -d "$1" ]; then | |
| echo "ERR! Path doesn't exist"; exit 1; | |
| fi | |
| ## Check for second param: | |
| if [ "$2" = "-s" ]; then | |
| ## Go through each mp4 file in path: | |
| find "$1" -maxdepth 1 -name "*.mp4" | while read -r file; do | |
| ## Strip out audio from file: | |
| input_file=$(basename "$file" .mp4) | |
| ffmpeg -y -i "$file" -vcodec copy -an "$1/${input_file}-Q.mp4" | |
| ## Remove source file: | |
| rm -rf "$1/${input_file}.mp4" | |
| ## Restore original filename: | |
| mv "$1/${input_file}-Q.mp4" "$1/${input_file}.mp4" | |
| ## Fix file perms: | |
| chmod +x "$1/${input_file}.mp4" | |
| done | |
| else | |
| echo "!!!THIS WAS DRY RUN, USE \`-s\` WHEN YOU'RE SURE!!!" | |
| fi | |
| ## List out processed files: | |
| echo -e "" | |
| find "$1" -maxdepth 1 -name "*.mp4" | while read -r file; do | |
| echo "- $(basename "$file" .mp4).mp4" | |
| done | |
| ## Notify user | |
| echo -e "\nDone!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment