#!/bin/sh
# All copy rights saved to Yehuda Korotkin
# You may use this script, but you must give credit
#
# email: yehuda@korotkin.co.il
#
if [ ! -d $1 ] ; then
echo "Usage: $0 <path> [FLAGS] "
echo
echo "Flags (Optional):"
echo " f = files only"
echo " d = folders only"
echo " x = (Default) files and folders"
echo
echo "Example:"
echo " $0 /some/where"
echo " OR "
echo " $0 /some/where f"
exit;
fi
SOURCE_DIR=$1
FIND_OPTIONS=""
case "$2" in
f)
FIND_OPTIONS=" --type f"
;;
d)
FIND_OPTIONS=" --type d"
;;
esac
for SRC in `find ${SOURCE_DIR} ${FIND_OPTIONS} -depth`
do
DST=`dirname "${SRC}"`/`basename "${SRC}" | cut -c 1 | tr '[A-Z]' '[a-z]'`
DST="$DST"`basename "${SRC}" | cut -c 2-`
if [ "${SRC}" != "${DST}" ]
then
[ ! -e "${DST}" ] && mv -T "${SRC}" "${DST}" || echo "${SRC} was not renamed"
fi
done
Back to top