User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
ml:dir [2020-06-30 13:00]
ziggi
ml:dir [2020-06-30 13:23] (current)
ziggi
Line 6: Line 6:
  *)  *)
  
-open Str;; +open Str 
-open Filename;; +open Filename 
-open Unix;;+open Unix
  
-let ext = "​.png"​;; +let ext = "​.png"​ 
-let tm time = Unix.localtime time;;+let tm time = Unix.localtime time
  
 let timestamp tm = Printf.sprintf let timestamp tm = Printf.sprintf
Line 17: Line 17:
     (tm.tm_year + 1900) tm.tm_mon tm.tm_mday     (tm.tm_year + 1900) tm.tm_mon tm.tm_mday
     tm.tm_hour tm.tm_min     tm.tm_hour tm.tm_min
-;; 
  
-let regex = Str.regexp "​^[a-zA-Z0-9_\\-]+.[pP][nN][gG]$"​;; +let regex = Str.regexp "​^[a-zA-Z0-9_\\-]+.[pP][nN][gG]$"​ 
-let is_png name = Str.string_match regex name 0;;+let is_png name = Str.string_match regex name 0
 let process name = let process name =
     if not (Sys.is_directory name) then     if not (Sys.is_directory name) then
Line 30: Line 29:
         let new_filename = (("​greenwood-"​ ^ timestamp (tm stat.st_ctime)) ^ "​-"​ ^ basename ^ ext) in         let new_filename = (("​greenwood-"​ ^ timestamp (tm stat.st_ctime)) ^ "​-"​ ^ basename ^ ext) in
             print_endline (dirname ^ "/"​ ^ new_filename)             print_endline (dirname ^ "/"​ ^ new_filename)
-;;+
 let main () = let main () =
     if (Array.length Sys.argv) > 1 then     if (Array.length Sys.argv) > 1 then
         let dir_list = Sys.readdir (Sys.argv.(1)) in         let dir_list = Sys.readdir (Sys.argv.(1)) in
-            Array.iter process dir_list +            Array.iter process dir_list;;
-;;+
  
-main ();;+main ()
 </​code>​ </​code>​