Skip to content

Instantly share code, notes, and snippets.

@yamasushi
Last active April 6, 2018 08:13
Show Gist options
  • Save yamasushi/4c4353a6e710758acec9 to your computer and use it in GitHub Desktop.
Save yamasushi/4c4353a6e710758acec9 to your computer and use it in GitHub Desktop.
#!/usr/bin/env gosh
; https://gist.github.com/yamasushi/4c4353a6e710758acec9
(use gauche.parseopt)
(use file.util)
(use srfi-11)
(define (main args) (let-args (cdr args)
( (help "h|help")
(ext-mode "x|ext" )
(str-rx "e=s") . rest-args )
(let [
(from (if (null? rest-args)
(home-directory)
($ expand-path $ car rest-args) ) )
(rx (string->regexp str-rx))
]
(format (standard-error-port) "~s files~%"
(directory-fold
from
(^ (entry result)
(let-values ( ((dir fname ext ) (decompose-path entry) ) )
;(print fname)
(if (rx (if ext-mode (if ext ext "") fname) )
(begin (print entry) (+ result 1) )
result ) ) )
0 ) ) )
) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment