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