#!/bin/bash guess_new_name() { local o_i d_i o_i="$1" d_i="$o_i" case "$d_i" in *", The") : ;; "10000 Maniacs") : ;; "Aphex Twin") : ;; "Altered Images") : ;; "Cabaret Voltaire") : ;; "Chemical Brothers") : ;; "China Crisis") : ;; "Cocteau Twins") : ;; "Frou Frou") : ;; "Global Communication") : ;; *" Compilations") : ;; "Joy Division") : ;; "Judge Dread") : ;; "Killing Joke") : ;; "Monserrat Monastery") : ;; "Natural Language") : ;; "New Order") : ;; "Popul Vuh") : ;; "Prefab Sprout") : ;; "Saint Etienne") : ;; "Schneider TM") : ;; "Scritti Politti") : ;; "Sebastian's Men") : ;; "si-{cut}.db") : ;; "Simple Minds") : ;; "Sing Sing") : ;; "Sleepy Motion") : ;; "Soft Cell") : ;; "Spacetime Continuum") : ;; "Spice Barons") : ;; "Sudden Sway") : ;; "Talking Heads") : ;; "Tangerine Dream") : ;; "Utah Saints") : ;; "Xmal Deutschland") : ;; *) # Change '-' to space, and add leading caps d_i="`echo \"$d_i\" | perl -pe 's/\b(\w)/\U$1/g; s/-/ /g;'`" # Change 'The Beatles' to 'Beatles, The' if expr "$d_i" : 'The .*' > /dev/null; then d_i="${d_i#The }, The" # Change 'Brian Eno' to 'Eno, Brian' (but be sure not # to change 'Eno, Brian' to 'Brian,, Eno') elif expr "$d_i" : '[^, ]* [^, ]*$' > /dev/null; then d_i="${d_i#* }, ${d_i% *}" fi ;; esac echo "$d_i" } for o_i in "$@"; do d_i="`guess_new_name \"$o_i\"`" # Get new name echo -n "$o_i [$d_i]: " read n_i [ "X$n_i" != X ] || n_i="$d_i" # If '.' then skip [ "X$n_i" != X. ] || continue # If identical skip [ "X$n_i" != "X$o_i" ] || continue # Rename it mv "$o_i" "$n_i" done