Welcome to the CHICKEN Scheme pasting service
Clueless about compilation problem added by pinkiesOut on Fri Jan 18 00:02:24 2013
#! /usr/local/bin/csi -ss (require-extension shell) (require-extension args) (require-extension posix) (define valid-extensions '("flv" "mov" "mp4" "wmv" "mkv" "mov" "avi" "mpg" "swf")) (define default-path "~/media/Television/") ;;; This does all the heavy lifting. It recursively scans the supplied ;;; directory, returning a list of file paths that end in any ;;; extension contained in valid-extensions. (define (file-list file-path) (find-files file-path test: (lambda (path) (member #t (map (lambda (ext) (string-suffix? ext path)) valid-extensions))))) ;;; You can print the available files with this (define (print-videos file-paths) (let ((video-names (map (lambda (path) (pathname-file path)) file-paths))) (for-each (lambda (l) (print l)) (sort (map string-titlecase video-names) (lambda (a b) (string< a b)))))) ;;; Computes how much memory all the video files are consuming ;;; on the HDD. The value returned is the total memory in GB (define (memory-used file-paths) (round (/ (apply + (map file-size file-paths)) (expt 1024 3)))) ;;; Available space on HDD. This is an ugly hack, but it returns ;;; the available space on the hard drive (in GB) (define (memory-free) (round (string->number (irregex-replace "\n" (capture ("df | grep '^/dev/' | awk '{s+=$4} END {print s/1048576}'")))))) (define (main args) (begin (if (null? args) (define video-file-paths (file-list default-path)) (define video-file-paths (file-list (car args)))) (newline) (print-videos video-file-paths) ;; Show the total space used? (printf "~%~A Videos Total. ~AGB used (~AGB free).~%~%" (length video-file-paths) (memory-used video-file-paths) (memory-free))))