Skip to content

Instantly share code, notes, and snippets.

@christf
Created January 11, 2017 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christf/2f19b4fd08715773c52e513b9d9d895f to your computer and use it in GitHub Desktop.
Save christf/2f19b4fd08715773c52e513b9d9d895f to your computer and use it in GitHub Desktop.
#!/bin/bash
output="$1"
dir="$2"
shopt -s nullglob
{
echo product-id: $((RANDOM%1024))
echo "media-path: $dir/%s"
echo "comment: An example GME file"
echo "init: $mode:=1"
echo "welcome: START"
echo "scripts:"
} > "$output"
count=8066
while IFS= read -r -d '' file
do
newfile=$(echo "${file##*/}"|tr -dc "a-zA-Z0-9_")
endung=${newfile: -3}
[[ "$file" != $dir/${newfile%$endung}.$endung ]] && mv "$file" "$dir/${newfile%$endung}.$endung"
done < <(find "$dir" -type f \( -name "*.mp3" -o -name "*.ogg" \) -print0)
for i in "$dir"/*.ogg "$dir"/*.mp3
do
if [[ "$i" != "$dir"/START.* ]]
then
echo " $count:"
fname=${i##*/}
echo " - P(${fname%.*})"
((count+=1))
fi
done >> "$output"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment