Скрипт для обработки записей asterisk
Немного поправил сам скрипт, теперь файлы раскидываются в папки вида “имя_месяца/число” независимо от того, под каким пользователем запускается скрипт. Можнадокому.
#!/bin/bash
#20100611 - Author: Gregg Hansen. Modified by Snake
#version 0.5
#http://www.khd.ru
#Make sure to install Lame and copy mlame to your .wav dir
#If you specify your own filenames, use NO spaces.
recorddir="/var/spool/asterisk/monitor"
for i in `ls $recorddir/*.wav`; do
month=`ls -l --time-style +'%b %d' $i | awk '{print $6}'`
day=`ls -l --time-style +'%b %d' $i | awk '{print $7}'`
mp3=`echo $i | cut -d "_" -f 2- | sed 's/.wav/.mp3/g'`
lame -d -h -m j -b 128 $i ${recorddir}/$mp3
if [ -d "${recorddir}/${month}" ];
then
if [ -d "${recorddir}/${month}/${day}" ];
then
mv ${recorddir}/${mp3} ${recorddir}/${month}/${day}
else
mkdir ${recorddir}/${month}/${day}
mv ${recorddir}/${mp3} ${recorddir}/${month}/${day}
fi
else
mkdir ${recorddir}/${month}
mkdir ${recorddir}/${month}/${day}
mv ${recorddir}/${mp3} ${recorddir}/${month}/${day}
fi
#Uncomment the below line if you want your .wavs moved to a different directory.
#This way you can review the timestamps and mp3 files before deleting the .wav
mkdir ${recorddir}/wav_recordings
mv $i ${recorddir}/wav_recordings/
done