Common Lisp hack to rename some videos
authorClinton Ebadi <clinton@unknownlamer.org>
Mon, 24 Nov 2014 03:01:20 +0000 (22:01 -0500)
committerClinton Ebadi <clinton@unknownlamer.org>
Mon, 24 Nov 2014 03:01:20 +0000 (22:01 -0500)
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 [new file with mode: 0644]

diff --git a/rename-x-files.lisp b/rename-x-files.lisp
new file mode 100644 (file)
index 0000000..1671545
--- /dev/null
@@ -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