Skip to content

Instantly share code, notes, and snippets.

@JustusAdam
Last active April 13, 2017 11:18
Show Gist options
  • Save JustusAdam/5faab5a741a9d5d3fd2f9d096bdc35d8 to your computer and use it in GitHub Desktop.
Save JustusAdam/5faab5a741a9d5d3fd2f9d096bdc35d8 to your computer and use it in GitHub Desktop.
Renames all direcories in the working directory by stripping a prefix. Leaves those who dont match the prefix unchanged.
-- Renames all direcories in the working directory by stripping a prefix
-- Leaves those who dont match the prefix unchanged.
import System.Directory
import Data.List
import System.Environment
import Control.Monad.Extra
main = getArgs >>= \[prefix] ->
listDirectory "." >>= filterM doesDirectoryExist >>= mapM_ (maybe (return()) (renameDirectory <$> (prefix++) <*> id) . stripPrefix prefix)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment