#!/bin/bash

<<comment
Converts wma, wav, flac, and mp3 audio files to 256kbps mp3 for use with the Zoom F1 field recorder. This version is only tested on linux, and requires ffmpeg to be installed, which usually is. At this time, it is a crude, hacked together script to get things done. A proper Python version is in the works. 

Place the Zoom_Converter.sh file in the folder with the audio files to be converted. You may need to make it executable. Fill in the destination area below, replacing "destination_path" with the full path of the files.

In terminal, use the "cd" command to change directories to the one containing the audio files and the Zoom_Converter.sh file. Ex: cd home/person/Music/Zoom_Converter. Then, from that directory, run: 

bash Converter.sh

The script will then open each file in the directory with ffmpeg and attempt to convert it to a 256kbps mp3 file if it matches the supported file types. The bitrate can be changed in the code by modifying "256k" parameter. 256k is the highest known bit rate tested on the Zoom F1. Reducing the file sizes by reducing the bit rate will not get around the device's hard limit of 500 files er SD card.

Created and tested on a Raspberry Pi 400 running Pop!_OS 21.10. 

comment

destination= destination_path
source=pwd

for f in source *.mp3; do
	ffmpeg -i "$f" -c:a libmp3lame -b:a 256k \
	"$destination/ ${f/%mp3/MP3}";
done

for f in source *.wav; do
	ffmpeg -i "$f" -c:a libmp3lame -b:a 256k \
	"$destination/ ${f/%wav/MP3}";
done
	
for f in source *.wma; do
	ffmpeg -i "$f" -c:a libmp3lame -b:a 256k \
	"$destination/ ${f/%wma/MP3}";
done
	
for f in source *.flac; do
	ffmpeg -i "$f" -c:a libmp3lame -b:a 256k \
	"$destination/ ${f/%flac/MP3}";
done
