Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # Copyright 2008 Octavio Ruiz
- # Distributed under the terms of the GNU General Public License v3
- # $Header: $
- #
- # Yet Another FLAC to MP3 script
- #
- # Author:
- # Octavio Ruiz (Ta^3) <tacvbo@tacvbo.net>
- # Thanks:
- # Those comments at:
- # http://www.linuxtutorialblog.com/post/solution-converting-flac-to-mp3
- # WebPage:
- # https://github.com/tacvbo/yaflac2mp3/tree
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY. YOU USE AT YOUR OWN RISK. THE AUTHOR
- # WILL NOT BE LIABLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY
- # OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.
- # See the GNU General Public License for more details.
- #
- # Modified by woohoo
- #
- # you need zenity package for notifications.
- # please note that you can put this script in ~/.gnome2/nautilus-scripts
- # and it will show up in right-click menu in any folder in gnome.
- #
- # modify the lame options to your preference example change -b 320 to -b 128 or -b 192 or -b 256
- # LAME_OPTS="--vbr-new -V 0 -b 256"
- # LAME_OPTS="-V 0 --vbr-new"
- LAME_OPTS="-b 320 -h --cbr"
- old_IFS=${IFS}
- IFS='
- '
- # when running from nautilus-scripts, it useful to find the current folder
- base="`echo $NAUTILUS_SCRIPT_CURRENT_URI | cut -d'/' -f3- | sed 's/%20/ /g'`"
- if [ -z "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then
- dir="$base"
- else
- while [ ! -z "$1" -a ! -d "$base/$1" ]; do shift; done
- dir="$base/$1"
- fi
- if [ "$dir" != "" ]; then
- cd "$dir"
- fi
- id3v2=$(which id3v2)
- files=`find . -type f -regex '^.+\.flac$' | sort`
- declare -i nn=0
- for file in ${files}
- do
- fn=$(readlink -f "$file")
- vars=( `metaflac --no-utf8-convert --export-tags-to=- "${fn}"` )
- for N_vars in ${!vars[@]}
- do
- export "$(echo "${vars[${N_vars}]%=*}" | tr [:upper:] [:lower:])=${vars[${N_vars}]#*=}"
- done
- dest=`echo "$fn"|sed -e 's/\.flac$/\.mp3/'`
- flac -dc "$fn" |\
- lame --ignore-tag-errors --add-id3v2 ${LAME_OPTS} \
- ${artist:+--ta} ${artist} \
- ${tracknumber:+--tn} ${tracknumber} \
- ${title:+--tt} ${title} \
- ${album:+--tl} ${album} \
- ${date:+--ty} ${date} \
- ${genre:+--tg} ${genre} \
- ${comment:+--tc} ${comment} \
- - $dest
- [[ -x ${id3v2} ]] && ${id3v2} \
- ${artist:+--artist} ${artist} \
- ${tracknumber:+--track} ${tracknumber} \
- ${title:+--song} ${title} \
- ${album:+--album} ${album} \
- ${date:+--year} ${date} \
- ${genre:+--genre} ${genre} \
- ${comment:+--comment} ${comment} \
- $dest
- let nn=nn+1
- done
- zenity --notification --text "Finished converting flac to mp3.${IFS}Processed ${nn} files."
- #zenity --info --text "Done!"
- IFS=${old_IFS}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement