
-- here was my original before I allowed someone (no names) to mangle mine for me ;) import Control.Monad (liftM, forM_) import Directory (getModificationTime, renameFile) import Text.Printf (printf) import System.FilePath ((>),(<.>)) import System.Locale (defaultTimeLocale) import System.Path.Glob (glob) import System.Time (toUTCTime, formatCalendarTime, getClockTime, ClockTime) basenames = ["mail.log", "thttpd.log" ] logdir = "/var/log" main = forM_ basenames $ \ basename -> do oldnames <- glob (logdir > basename <.> "*.gz") forM_ oldnames $ \ oldname -> do now <- timestamp oldname let newname = logdir > "archive" > basename <.> now <.> "gz" printf "mv %s %s" oldname newname renameFile oldname newname timestamp path = do t <- getModificationTime path return $ formatCalendarTime defaultTimeLocale "%Y%m%d" $ toUTCTime t