fork download
  1. import Data.List
  2. import System.Directory
  3. import Text.Regex.PCRE
  4. import System.FilePath.Glob
  5. import Text.Printf
  6. import Control.Monad
  7. mymatch :: String -> String -> (String,String,String)
  8. mymatch str ptn = str =~ ptn
  9.  
  10. main = do
  11. files <- glob "abc*.mp4"
  12. let l = map (reverse . takeWhile (/= '/') . reverse) files
  13. ll =map (words . f) l
  14. in
  15. mapM_ (\[a,b] -> renameFile a b) ll
  16. where
  17. f x =let (_,y,_) = mymatch x "\\d+" in
  18. intercalate " " $ [x,"abc" <> printf "%03d" (read y::Int) <> ".mp4"]
  19.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:3:1: error:
    Could not find module ‘Text.Regex.PCRE’
    Use -v to see a list of the files searched for.
  |
3 | import Text.Regex.PCRE
  | ^^^^^^^^^^^^^^^^^^^^^^

prog.hs:4:1: error:
    Could not find module ‘System.FilePath.Glob’
    Perhaps you meant
      System.FilePath (from filepath-1.4.2)
      System.FilePath.Posix (from filepath-1.4.2)
    Use -v to see a list of the files searched for.
  |
4 | import System.FilePath.Glob
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
stdout
Standard output is empty