Created
September 28, 2014 17:00
-
-
Save miguel-negrao/368099c3d7e426f09b30 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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