From: Clinton Ebadi Date: Mon, 24 Nov 2014 03:01:20 +0000 (-0500) Subject: Common Lisp hack to rename some videos X-Git-Url: http://git.hcoop.net/clinton/scratch.git/commitdiff_plain/34f4b089106d126f0788eedb688d066b97aabdb7?ds=inline Common Lisp hack to rename some videos X-Files file names in my copy of Season 01 were making xbmc unhappy, use fad and cl-ppcre to move them. Because `rename' doesn't exist (d'oh). --- diff --git a/rename-x-files.lisp b/rename-x-files.lisp new file mode 100644 index 0000000..1671545 --- /dev/null +++ b/rename-x-files.lisp @@ -0,0 +1,13 @@ +(mapcar #'ql:quickload '(:cl-fad :cl-ppcre)) + +(defun copy-season (source target) + (fad:walk-directory source + (lambda (x) (multiple-value-bind (target-name matched?) + (ppcre:regex-replace ".*/([0-9]{2})[.]([0-9]{2})[.](?:[0-9]{2})- (.*)" + (namestring x) + '("Season " 0 " Episode " 1 " - " 2)) + (when matched? + (format t "matched, copying: ~A / ~A~%" x target-name) + (fad:copy-file x (merge-pathnames target-name (make-pathname :directory `(:absolute ,target))))))))) + +"/srv/archive/video/tv/The X-Files/Season 01" \ No newline at end of file