#-- *--*--*--*--*--*--*--*--*--*--*--*--*-- #-- SCRIPT: #-- tran.sh #-- DESCRIPTION: #-- This script uses the file names of sound files #-- (wav at present) to lookup english translations on #-- on the internet (using wget). #-- The web-site used is #-- http;//www.spanishdict.com/ #-- AUTHOR: #-- mj bishop #-- DATE: #-- may 02 #-- *--*--*--*--*--*--*--*--*--*--*--*--*--*-- if [ -n "$1" ] then sSaveFile=$1 rm $sSaveFile else sSaveFile="dict123.txt" rm dict123.txt fi echo " Starting to translate words [ based on file names ] ... (Saving words & translations ---> $sSaveFile) ----------------------- " for sFile in [a-zA-Z-]*.wav do #-- initialize variables sWord="" sEnglish1="" sEnglish2="" sEnglish3="" sWord=$(echo $sFile | sed 's/\..*$//g') echo "File Name=$sFile " echo "Word=$sWord " echo "File Name=$sFile " >> $sSaveFile echo "Word=$sWord " >> $sSaveFile #-- Extract the word translations from the #-- returned html page. wget -o temp.txt -O - -nd http://www.spanishdict.com/AS.cfm?e=$sWord | grep -A1 'ED.cfm' | sed -e '/ED\.cfm/d' -e 's/<\/a>//g' > tsave1.txt cat tsave1.txt | expand | sed -e '/\-/d' -e 's/^ *//g' -e 's/ *$//g' > tsave.txt sEnglish1=$(head -1 tsave.txt) sEnglish2=$(head -2 tsave.txt | tail -1) sEnglish3=$(head -3 tsave.txt | tail -1) if [ "$sEnglish2" == "$sEnglish1" ] then sEnglish2="" sEnglish3="" fi echo "English1=$sEnglish1" echo "English2=$sEnglish2" echo "English3=$sEnglish3" echo "=" # cat tsave.txt echo "English1=" >> $sSaveFile echo "English2=" >> $sSaveFile echo "English3=" >> $sSaveFile # cat tsave.txt >> $sSaveFile echo "=" >> $sSaveFile done