#!/bin/sh
: ; exec klone $0 "$@"
; The above line finds the klone executable in the $PATH
;;Skeleton of a typical klone script
;;(stack-dump-on-error t)
;;(kdb t)
(setq args (getopts "USAGE: file-case files...
recursively rename file and dir arguments to lower/upper case"
("-l" () tolower? "convert files and dirs to lower case (default)")
("-u" () toupper? "convert files and dirs to upper case")
("-v" () verbose "verbose operation")
))
(defun main (&aux
)
(dolist (file args)
(if (= 'directory (file-type file))
(progn
(convert-dir file)
(convert-file file)
)
(not (file-type file))
(print-format "*** FILE NOT FOUND, IGNORED: %0\n" file)
(convert-file file) ;rename files and dirs
)
)
)
(defun convert-file (file &aux
(new (if toupper? (toupper file) (tolower file)))
)
(if (/= new file) (progn
(if verbose (print-format " %0 ==> %1\n" file new))
(wait (system (list "mv" file new)))
))
)
(defun convert-dir (dir &aux ;recurse in dirs
(*current-directory* dir)
)
(if verbose (print-format "======BEGIN DIR: %0\n" *current-directory*))
(dolist (file (directory))
(if (= 'directory (file-type file))
(convert-dir file)
)
(convert-file file)
)
(if verbose (print-format "======END DIR: %0\n" *current-directory*))
)
(main)
;;; EMACS MODES
;;; Local Variables: ***
;;; mode:lisp ***
;;; End: ***
syntax highlighted by Code2HTML, v. 0.9.1