Skip to content

Instantly share code, notes, and snippets.

@miguel-negrao
Created September 28, 2014 17:00
Show Gist options
  • Save miguel-negrao/368099c3d7e426f09b30 to your computer and use it in GitHub Desktop.
Save miguel-negrao/368099c3d7e426f09b30 to your computer and use it in GitHub Desktop.
module Main where
import System.Directory
import Control.Monad (when)
rename :: String -> String
rename xs = "20"++take 2 xs++"_"++f 2++"_"++(take 5 $ drop 4 xs)++"_"++f 9++"_"++drop 11 xs
where f n = take 2 $ drop n xs
main :: IO ()
main = do
path <- getCurrentDirectory
files <- getDirectoryContents path
let filesToRename = filter (\xs -> take 2 xs == "14" && (reverse.(take 3).reverse) xs == "WAV") files
when (filesToRename /= []) $ do
putStr $ unlines $ ("Files to rename:":filesToRename)++["Want to rename (y/n)?"]
answer <- getLine
when (answer == "y") $ do
putStrLn "renaming..."
mapM (\x -> renameFile x $ rename x) filesToRename
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment