packages feed

augur-2008.10.19: src/Rename.hs

module Rename where

import Config
import Parse
import Storage

import System.FilePath
import Control.Monad
import System.Directory

rename :: Config -> String -> [FilePath] -> IO ()
rename cfg format paths
    = do ppNames <- parse cfg format (map takeFileName paths)
         forM_ (zip paths ppNames) $ \(path, parsed) ->
             do let dest = dropFileName path </> parsed
                when (confVerbose cfg >= 2) $ putStrLn $ path ++ " -> " ++ dest
                unless (confDryRun cfg) $ renameFile path dest