#! /bin/sh set -e cmd="`basename \"$0\"`" case "$cmd" in cp_*) cmd="cp -ap" ;; mv_*) cmd=mv ;; *) echo "Unknown command $0, aborting" >&2 exit 2 ;; esac . get_encodings if [ -z "$1" ]; then echo "Usage: $0 [-f from_encoding] [-t to_encoding] path [path ...]" >&2 exit 1 fi for filename in "$@"; do filename_recoded=`echo "$filename" | iconv -f "$from_encoding" -t "$to_encoding"` if [ "$filename_recoded" != "$filename" ]; then $cmd "$filename" "$filename_recoded" fi done