]> git.phdru.name Git - dotfiles.git/blob - bin/cleanup-filenames.sh
c977312b8d06eec9a90b121868c04edfd35fcc3b
[dotfiles.git] / bin / cleanup-filenames.sh
1 #! /bin/sh
2
3 if ! echo "$LC_CTYPE" | grep -Fiq utf-8; then
4    echo "This script requires UTF-8 locale" 1>&2
5    exit 1
6 fi
7
8 for fname in "$@"; do
9
10    newname=$(echo "$fname" | sed -e "
11 s/[‘“’”‘“’”″′«»\`\"]/'/g
12 s/ *: */ - /g
13 s/[–—]/-/g
14 s/…/.../g
15 s/ \+/ /g
16 s/\?//g
17 s/№/N/g
18 ")
19
20    if [ "$fname" \!= "$newname" ]; then
21       echo "$fname"
22       echo "$newname"
23       mv -- "$fname" "$newname"
24       echo
25    fi
26 done