Created
August 29, 2013 22:31
-
-
Save loreb/6384208 to your computer and use it in GitHub Desktop.
A little script for my mom's new cell -- explaining just didn't work :)
"suoneria" is the italian word for "ringtone"
This file contains 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/sh | |
# Original msgs edited or stripped (they were in italian); | |
# iirc knoppix localizes sell scripts, I don't care. | |
zdie() { | |
zenity --error --text="$*" --no-markup | |
exit 123 | |
} | |
set -e # 99% of all shell scripts just **assume** things work... | |
song="$(zenity --file-selection)" | |
test -s "$song" || zdie "$song???" | |
start="$(zenity --text "from" --entry-text 0 --entry)" | |
end="$(zenity --text "to" --entry-text 1:23 --entry)" | |
i=0 | |
BASE="${song##*/}" # basename | |
while [ $i -lt 12345 ] ; do | |
# - 'z' to line up cleanly separated from other files; | |
# - force mp3, my mom's cellphone doesn't grok .ogg; | |
# This breaks on windows because of ':' in filenames. | |
output="z$i $BASE $start $end".mp3 | |
i=$(($i + 1)) | |
if [ -e "$output" ] ; then | |
continue | |
fi | |
sox "$song" "$output" trim "$start" "$end" && exit | |
done | |
zdie "canthappen XD" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment