Last active
July 21, 2016 13:02
-
-
Save miguel-negrao/efc8d1d926a4ada48505c652f1c24c0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Convert filenames generated by ZOOM sound recorders to sensible ones like 2016-07-19 22:02 2chs 24bits 44100Hz.WAV