Created
August 14, 2012 03:26
-
-
Save NalaGinrut/3346059 to your computer and use it in GitHub Desktop.
patches set name fixing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/guile \ | |
-e main -s | |
!# | |
(use-modules (ice-9 regex) (ice-9 ftw)) | |
(define (sub from to str) (regexp-substitute #f (string-match from str) 'pre to 'post)) | |
(define (usage args) (format #t "~a from to path~%" (car args))) | |
(define main | |
(lambda (args) | |
(and (< (length (cdr args)) 3) (usage args) (primitive-exit)) | |
(let* ((from (cadr args)) (to (caddr args)) (path (cadddr args)) (fl (cddr (scandir path)))) | |
(for-each (lambda (file) (let ((f (string-append path "/" file))) (rename-file f (sub from to f)))) fl)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment