ga-infounused: Use `--no-textconv` in `git diff`
[sunny256-utils.git] / oggname
blob3bd89e6bbb839c04ad9e09e5a070e144cb8a6389
1 #!/usr/bin/env bash
3 #=======================================================================
4 # oggname
5 # File ID: dd535e78-5d41-11df-937b-90e6ba3022ac
7 # Skifter navn på musikkfiler til sånn som jeg liker det:
8 # Bandnavn_-_Platetittel_-_Sangnummer_-_Sangtittel.ext
10 # Author: Øyvind A. Holm <sunny@sunbase.org>
11 # License: GNU General Public License version 2 or later.
12 #=======================================================================
14 progname=oggname
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 Usage: $progname [options]
51 Options:
53 -h, --help
54 Show this help.
55 -q, --quiet
56 Be more quiet. Can be repeated to increase silence.
57 -v, --verbose
58 Increase level of verbosity. Can be repeated.
59 --version
60 Print version information.
62 END
63 exit 0
66 patt='*.flac *.mp3 *.ogg'
67 echo ==== Space til understrek
68 prename -v 's/ /_/g' $patt | perl -pe 's/ renamed as /\n/'
69 echo ==== Alle bokstaver til små
70 prename -v 'y/[A-Z]/[a-z]/' $patt | perl -pe 's/ renamed as /\n/'
71 echo ==== Forbokstaver i bandnavn til stor
72 prename -v 's/^(.*?)_([a-z])(.*?)_-_/$1_\U$2\E$3_-_/g' $patt | perl -pe 's/ renamed as /\n/'
73 echo ==== Første bokstav i filnavnet til stor
74 prename -v 's/^([a-z])/\U$1\E/' $patt | perl -pe 's/ renamed as /\n/'
75 echo ==== Første bokstaven i sangtittelen til stor
76 # prename -v 's/^(.*)_-_([a-z])(.*?)$/$1_-_\U$2\E$3/' $patt | perl -pe 's/ renamed as /\n/'
77 prename -v 's/_-_([a-z])/_-_\U$1\E/g' $patt | perl -pe 's/ renamed as /\n/'
78 echo ==== «I» til stor bokstav
79 prename -v 's/_i_/_I_/g' $patt
80 echo === Apostrofer til U+2019
81 prename -v "s/'/’/g" $patt