Skip to content

Commit b5fa4a2

Browse files
committed
Adding --help mode and update in README to same change
For the program to more easily take arguments as well as make using the program much more simple, the way to use the program is changed. You now feed the program the directory containing the files to rename instead of every single file that you would like renamed.
1 parent e181c75 commit b5fa4a2

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ What it does:
55
Provides a simple way to rename similarly named files at the same time
66

77
How to use:
8-
./batch_rename.scm [function taking arguments 'totalnumberoffiles' 'filename to change'] [files separated by spaces]
8+
9+
batch_rename [options]
10+
-h, --help Display this help
11+
-f, --function [lambda expression] A Lambda expression accepting totalfilecount and current file as arguments and returning the altered filename
12+
-d, --directory [Directory] The directory containing the files that function will act on

batch_rename.scm

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
11
#!/usr/local/bin/guile \
22
-e main -s
33
!#
4+
(use-modules (ice-9 getopt-long))
5+
6+
(define help_display "\
7+
8+
batch_rename [options]
9+
-h, --help Display this help
10+
-f, --function [lambda expression] A Lambda expression accepting totalfilecount and current file as arguments and returning the altered filename
11+
-d, --directory [Directory] The directory containing the files that function will act on
12+
13+
")
14+
415
(define (main args)
5-
(write args)
16+
(define option-spec
17+
'((function (single-char #\f) (value optional))
18+
(directory (single-char #\d) (value optional))
19+
(help (single-char #\h) (value #f))))
20+
(define options (getopt-long args option-spec))
21+
(define function-code (option-ref options 'function #f))
22+
(define directory-name (option-ref options 'directory #f))
23+
(define help-wanted (option-ref options 'help #f))
24+
(if help-wanted
25+
(display help_display))
26+
(write "function-code: ")
27+
(write function-code)
28+
(newline)
29+
(write "directory-name: ")
30+
(write directory-name)
631
(newline))
7-

0 commit comments

Comments
 (0)