4 echo 'Usage: ${0} -p prefix [-d directory] [-t extension] [-u]'
5 echo " -p prefix to be removed"
6 echo " -d destination folder"
7 echo " default current directory"
8 echo " -t files extension"
10 echo " -u encode filename in UTF-8"
11 echo '---------------------'
16 echo processing "${@}"
17 newfile=`echo "$@" | sed "s/${prefix}//g"`
18 [ -n ${iconv} ] && newfile=`echo ${newfile} | iconv -c -t UTF-8`
19 echo " : copying <$newfile> into <${dest}>"
20 cp "${@}" "${dest}/${newfile}"
23 while getopts "p:d:t:u" option
47 [ -z "${dest}" ] && usage && exit 1
48 [ -z "${prefix}" ] && usage && exit 1
51 echo "Copy and rename ${ext} files, removing <${prefix}> prefixes, into <${dest}>."
52 [ -n "${iconv}" ] && echo '* Filename UTF-8 encoding is on.'
54 mkdir -p "${dest}" || (echo "unable to create ${dest}" && exit 1)
56 find . -maxdepth 1 -type f -name "*.${ext}" -print | while IFS= read file; do processing "${file}" ; done