#!/usr/bin/env clisp ;;;; Copies/backs up a file ;;;; The new file gets .YYYYMMDDHHMMSS appended to the filename ;;;; Nothing in the original file is changed ;; Build the YYYYMMDDHHMMSS string (defun time-suffix () (multiple-value-bind (second minute hour day month year) (get-decoded-time) (format nil "~d~2,'0d~2,'0d~2,'0d~2,'0d~2,'0d" year month day hour minute second))) ;; Build the file name for the backup file (defun backup-file-name (file-name) (format nil "~A.~A" file-name (time-suffix))) ;;Perform the backup (defun backup (file-name) (let ((new-file-name (backup-file-name file-name))) (format t "Copying file ~A to ~A" file-name new-file-name) (copy-file file-name new-file-name))) (defun main () (let ((file-name (first ext:*args*))) (if (equal nil file-name) (format t "You did not supply a file name") (backup file-name) ))) (main)