installed_progs.t: Python checks stdout too, 150 ok
[sunny256-utils.git] / fix_filenames
bloba3f6040dd093b58b3304e968d4dc38c929a773d9
1 #!/usr/bin/env bash
3 #=======================================================================
4 # fix_filenames
5 # File ID: 368543a6-5d3a-11df-91ac-90e6ba3022ac
7 # Change spaces in file names to '_' and convert ASCII apostrophes to
8 # U+2019.
10 # Author: Øyvind A. Holm <sunny@sunbase.org>
11 # License: GNU General Public License version 2 or later.
12 #=======================================================================
14 progname=fix_filenames
15 VERSION=0.2.0
17 ARGS="$(getopt -o "\
21 " -l "\
22 help,\
23 quiet,\
24 verbose,\
25 version,\
26 " -n "$progname" -- "$@")"
27 test "$?" = "0" || exit 1
28 eval set -- "$ARGS"
30 opt_help=0
31 opt_quiet=0
32 opt_verbose=0
33 while :; do
34 case "$1" in
35 -h|--help) opt_help=1; shift ;;
36 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
37 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
38 --version) echo $progname $VERSION; exit 0 ;;
39 --) shift; break ;;
40 *) echo $progname: Internal error >&2; exit 1 ;;
41 esac
42 done
43 opt_verbose=$(($opt_verbose - $opt_quiet))
45 if test "$opt_help" = "1"; then
46 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
47 cat <<END
49 Change spaces in file names to '_' and convert ASCII apostrophes to
50 U+2019.
52 Usage: $progname [options]
54 Options:
56 -h, --help
57 Show this help.
58 -q, --quiet
59 Be more quiet. Can be repeated to increase silence.
60 -v, --verbose
61 Increase level of verbosity. Can be repeated.
62 --version
63 Print version information.
65 END
66 exit 0
69 prename -v 's/ /_/g' "$@"
70 prename -v "s/'/’/g" "$@"