Created
November 15, 2025 15:12
-
-
Save larouxn/e5e6bde21fa79647a641a8c807a10c4b to your computer and use it in GitHub Desktop.
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 | |
| # Set the directory to start from. "." means the current directory. | |
| START_DIR="." | |
| # Use 'find' to locate all .aiff and .aif files, then pipe them to a 'while' loop. | |
| # -type f: finds only files | |
| # \( ... \): groups conditions | |
| # -name "*.aiff" -o -name "*.aif": finds files ending in .aiff OR .aif | |
| find "$START_DIR" -type f \( -name "*.aiff" -o -name "*.aif" \) | while read -r aiff_file; do | |
| # Create the new .flac filename by replacing the old extension | |
| # ${aiff_file%.*} removes the extension (e.g., "song.aiff" -> "song") | |
| flac_file="${aiff_file%.*}.flac" | |
| echo "---------------------------------" | |
| echo "Converting: $aiff_file" | |
| # Run the robust ffmpeg command | |
| # Using quotes ("$aiff_file") is vital to handle filenames with spaces | |
| ffmpeg -i "$aiff_file" -map 0 -map_metadata 0 -c:a flac -c:v copy "$flac_file" | |
| echo "Created: $flac_file" | |
| rm "$aiff_file" | |
| echo "Deleted: $aiff_file" | |
| done | |
| echo "---------------------------------" | |
| echo "Batch conversion complete! 🎵" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment