Created
October 25, 2025 18:31
-
-
Save renegarcia/872564a13a2cc8f929f38ff1723356f2 to your computer and use it in GitHub Desktop.
Convert every .mp4 file in the current directory to OGG Vorbis and place the resulting .ogg files in a sibling folder versioned by date-time
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
| #!/usr/bin/env fish | |
| # ------------------------------------------------------------ | |
| # Convert every .mp4 file in the current directory to OGG Vorbis | |
| # and place the resulting .ogg files in a sibling folder | |
| # called "archivos-audio". | |
| # ------------------------------------------------------------ | |
| # 1. Create the destination folder if it doesn't exist | |
| set timestamp (date +"%Y-%m-%dT%H%M%S") | |
| set dest "converted-audio-$timestamp" | |
| if not test -d $dest | |
| mkdir $dest | |
| end | |
| # 2. Loop over all .webm files (non‑recursive) | |
| for src in *.mp4 | |
| # Skip if the glob didn't match any files | |
| if not test -e $src | |
| continue | |
| end | |
| # Build the output filename (same base name, .ogg extension) | |
| set base (basename "$src" .mp4) | |
| set out "$dest/$base.ogg" | |
| # 3. Run ffmpeg: copy video away, copy audio as is, in case audio | |
| # is already in a format supported by ogg, eg vorbis or opus. | |
| # If you want to encode audio to Vorbis -q:a 5 gives a good | |
| # quality‑size trade‑off (0‑10 scale). To transcode use ffmpeg | |
| # as this: | |
| # ffmpeg -i "$src" -c:a libvorbis -q:a 5 -vn "$out" | |
| ffmpeg -i "$src" -c:a copy -vn "$out" | |
| # Optional: print a short status line | |
| echo "Converted $src → $out" | |
| end | |
| echo "All done. OGG files are in ./$dest" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment