Image Image Image Image Image
Scroll to Top

To Top

sound_recording

21

Jul
2016

No Comments

In code

By admin

Create sensible file names for files from ZOOM audio recorders

On 21, Jul 2016 | No Comments | In code | By admin

Zoom recorders name their files ZOOM0001.WAV, etc. This is not terrible informative. I made a script to auto-generate file names based date of modification of file (to be accurate you need to set the date correctly in the recorder). It is a Haskell script using the turtle and WAVE packages. To run it make sure the packages are installed and do “runhaskell rename_zoom.hs /path/to/your/files”.

{-# LANGUAGE OverloadedStrings #-}
import Turtle hiding (x, options)
import qualified Data.Text as T
import System.Environment (getArgs)
import Data.Time.Format
import Data.WAVE
main :: IO ()
main = do
args <- getArgs
let dir = case args of
a:_ -> a
[] -> "."
sh $ do
path <- ls $ fromText $ T.pack dir
t <- liftIO $ datefile path
echo $ format ("Reading "%fp) path
wve <- liftIO $ getWAVEFile $ T.unpack $ format fp path
let
WAVEHeader chs hz bits _ = waveHeader wve
waveString = format (" "%d%"chs "%d%"bits "%d%"Hz.WAV") chs bits hz
newFileName = T.pack (formatTime defaultTimeLocale "%F %R" t) <> waveString
newPath = directory path </> fromText newFileName
echo $ format ("Renaming "%fp%" to "%fp) path newPath
liftIO $ mv path newPath

Tags | ,