Here is something I wrote years ago. I expect you can adjust it for your needs
# cat remove_blank_vmail #!/bin/bash # remove_blank_vmail takes arguments as voicemail boxes and removes messages with audio files shorter then MINSIZE (in bytes) #---------------------------------------------------------------------- # Description: # Author: John Harragin Monroe-Woodbury CSD # Created at: Thu Nov 6 12:27:35 EST 2008 # # Copyright: None. Modify and use however you like... # #---------------------------------------------------------------------- # Configure section: BASEDIR=/var/spool/asterisk/voicemail/default/ # default context MINSIZE=12000 # 1.5 seconds #--------------------------------------------------------------subroutines: ProcessDir () { lastfile="" delcnt=0 for file in $(ls -A ${msgdir}/msg*.txt 2>/dev/null); do # the redirect supresses msg when dir empty if [ $(stat --format=%s ${file/.txt/.wav}) -lt ${MINSIZE} ]; then rm ${file/.txt/.*} let delcnt++ fi lastfile=${file} done if [ $delcnt -gt 0 ]; then echo "$delcnt short messages deleted from ${msgdir}"; fi partfilename=${lastfile/*\/msg/} # get number from file name highest=${partfilename/.txt/} while [[ $highest = 0* ]]; do highest=${highest#0}; done # bash does not like leading zeros if [ ${#highest} -eq 0 ]; then highest=0; fi # ...or blanks for math realcount=0 for ((x=0;x<=${highest};x+=1)); do chkname=msg$(printf "%04d" $x) # build name - pad with zeros... if [ -e ${msgdir}/${chkname}.txt ]; then if [ $realcount -ne $x ];then newname=msg$(printf "%04d" $realcount) for idivfile in $(ls -A ${msgdir}/${chkname}.*); do mv ${idivfile} ${msgdir}/${newname}.${idivfile/*\/*./} done fi let realcount++ fi done } #--------------------------------------------------------------main: for ext in "$@"; do if [ -d ${BASEDIR}${ext} ];then for msgdir in $(ls -d ${BASEDIR}${ext}/*); do ProcessDir ${msgdir} done else echo "${BASEDIR}${ext} is not a valid directory" fi echo "Processed extension $ext" done On Mon, Oct 9, 2023 at 3:06 PM Mike Diehl <mdi...@diehlnet.com> wrote: > Hi all, > > I need to be able to delete a voicemail message using a program. > > Is is sufficient to simply delete the .wav and .txt files in the spool > directory? > Or do I need to also renumber the remaining files? > > For example, let say a given mailbox has 20 messages in it and I want to > delete message number 5. Can I just delete the 2 files and expect that > asterisk will renumber them? Or do I need to? > > Also, is the answer the same when I migrate to storing voicemails in a > database? > > Thanks in advance. > > Mike > > > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > Check out the new Asterisk community forum at: > https://community.asterisk.org/ > > New to Asterisk? Start here: > https://wiki.asterisk.org/wiki/display/AST/Getting+Started > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users
-- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- Check out the new Asterisk community forum at: https://community.asterisk.org/ New to Asterisk? Start here: https://wiki.asterisk.org/wiki/display/AST/Getting+Started asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users