Voicemail "msg0001.wav" naming scheme issue


This is a little complicated, so I will do my best to state this issue clearly. When there is a new voicemail, the file name increments in number. Your first voicemail will be “msg0001.wav”, your second will be “msg0002.wav” and so on.

Here is what my problem is. I have a customer who we have set a max message limit of 150 messages. We also remove voicemails from the system that are older than 30 days. The issue I’m seeing is that the counter does not reset. The message number continues to go up until it is named “msg0150.wav”. Once it hits that number, every new voicemail will be named “msg0150.wav”. We have voicemail to email setup and for users who have a lot of voicemails, this becomes a problem because they all have the same name.

Is their a simply way to have the counter reset it self occasionally? Or parse the current date into the file name to make it unique?

Any thoughts or suggestions are much appreciated.

How is this done.

We am using a pearl script I found here

And I’m a little embarassed to say I didn’t look at my script before I wrote in the forum for help. It seems that the script does have a renaming function in it, but I’m not well versed in Pearl, so I am not sure if it is causing the problem.

You’ve helped point me in the right direction and it looks like this may be what is causing out issue. This is probably beyond the scope of these forums, but if you know some Pearl and have a look, I would be curious to see what you think.


The scripts you are using is a hack of part of the asterisk distribution, the original one is


It is written in perl (not Pearl) and kinda of shows how comedian mail works and some insight into the “shell sort” read and deleted messages of the original c code.

I suggest you get a copy of the original , it works just fine.

1 Like

That sounds great. Forgive me ignorance, but where is conrtrib/scripts/messages-expire.pl? Do you know what the absolute path or parent directory for this is?

And yes, “Pearl” didn’t look right, but I couldn’t remember why.

You can download the source code , perhaps


and extract it from there.