#!/bin/bash
#from为压缩包批次所在目录
#basetarpath to count the total length of time per batch
From=$1
Basetarpath=$2
suffix= "Tgz"
Todir= $basetarpath
outdir= $basetarpath/home/iflytek/out
if [!-d? $from]; Then
Exit
Fi
if [!-D $basetarpath];then
Mkdir-p $basetarpath
Fi
function Jieya () {
? ? for element in
ls $1
? ? Do??
? ? ? ? Dir_or_file=$1 "/" $element
? ? ? ? If [-D $dir _or_file]
? ? ? ? Then?
? ? ? ? ? ? Jieya $dir _or_file
? ? ? ? Else
? ? ? ? ? ? if ["${dir_or_file##*.}" = "tgz"]; Then
TAR-ZXVF $dir _or_file-c $todir?
? ? ? ? ? ? Fi?
Fi??
? ? Done
? ? echo "tar success"??
}
function Taltoltime () {
Cat $ | While Read Myline
Do
? ? ? ? var=$ (cat $myline | grep "Time")
? ? ? ? if [[$var! = ""]]; Then
var=${var//"Time:"/|}
? ? ? ? ? ? ? ? Array= (${var//|/})
? ? ? ? ? ? ? ? For var2 in ${array[@]}
? ? ? ? ? ? ? ? Do
? ? ? ? ? ? ? ? ? ? ? ? Arraylr= (${var2//,/})
voicetime=$ (($voicetime +$ ((${arraylr[1]}-${arraylr[0)})))
? ? ? ? ? ? ? ? ? ? ? ? echo $voicetime??>
? ? ? ? ? ? ? ? Done
? ? ? ? Fi
Done
}
function Iterate () {
? ? for element in $outdir/????
? ? Do
CD $outdir
echo 0;? ${element##/}.txt
For onetxt in $element/
Do
voicetime=$ (cat ${element##/}.txt)
Taltoltime $onetxt $voicetime ${element##*/}.txt
Done
? ? Done
? ? echo "Success"
}
Jieya $from
Iterate
Shell unzip the package to find the sum of all the text's recording duration