Saving old voicemails with bash
After 3 years with my trusty iPhone 4S, I finally upgraded. But I wanted retain all my voicemails mostly for sentimental reasons because the only people who leave me voicemails anymore are my fiance or parents. This article had almost everything I needed. But I ran into a minor snafu as the number of files is too great for the file command, and in typical engineer fashion, wanted to automate more. First, follow the first few steps in the above article. Now, from your backup directory, try running this instead:
for l in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do file $l* | grep GSM | cut -b 1-40 | xargs -I % cp % ~/Voicemails/; done
What this does is iterate through all possible starting characters (0-f) to prevent the “too many arguments” error. Then we look at the file type and get all those that contain “GSM”. Using cut, we get just the file name. Then, we copy that file into a directory of our choosing.
Finally, from our new voicemails directory we add the file extension to make previewing easier:
cd ~/Voicemails && for f in *; do mv "$f" "$f.amr"; done
It’s a fun little puzzle to automate things with bash, but the more I do it, the more time I save.