Skip to content

Instantly share code, notes, and snippets.

@0xdeadbeer
Created May 4, 2025 11:20
Show Gist options
  • Save 0xdeadbeer/ccebd5948a14d4af59bdff1c07c0d2d6 to your computer and use it in GitHub Desktop.
Save 0xdeadbeer/ccebd5948a14d4af59bdff1c07c0d2d6 to your computer and use it in GitHub Desktop.
Rename from yt-dlp ugly naming convention to snake_case
#!/usr/bin/bash
for file in ./*.mp3
do
new_file=$(echo "$file" | sed 's/\.\///g' | sed 's/\[[^]]*\]//g' | sed 's/([^)]*)//g' | sed 's/\.[^.]*$//g' | sed 's/[^a-zA-Z :]//g' | awk '{$1=$1;print}' | sed 's/ /_/g' | tr '[:upper:]' '[:lower:]' | sed 's/$/.mp3/g')
echo "old file name: '$file'"
echo "new file name: '$new_file'"
echo ""
mv "$file" "$new_file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment