From 34f4b089106d126f0788eedb688d066b97aabdb7 Mon Sep 17 00:00:00 2001 From: Clinton Ebadi Date: Sun, 23 Nov 2014 22:01:20 -0500 Subject: [PATCH 1/1] 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). --- rename-x-files.lisp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 rename-x-files.lisp 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 -- 2.20.1