Hello Venkat
On *n*x computers, unlike Windows, file names which differ in case are different; foo, Foo, fOO etc. are different mames. So copying Foo into a directory will not replace foo.
If it's possible, the easiest for you would be to change all the filenames to the same case.
Here's a script from the Advanced Bash Scripting Guide that says it will do it
Code:
#!/bin/bash
#
# Changes every filename in working directory to all lowercase.
#
# Inspired by a script of John Dubois,
#+ which was translated into Bash by Chet Ramey,
#+ and considerably simplified by the author of the ABS Guide.
for filename in * # Traverse all files in directory.
do
fname=`basename $filename`
n=`echo $fname | tr A-Z a-z` # Change name to lowercase.
if [ "$fname" != "$n" ] # Rename only files not already lowercase.
then
mv $fname $n
fi
done
exit $?
I'm a little worried by some aspects of this script like it renames directories as well as files (maybe that's OK) and if you start with Foo, FOO and foo then you will end up with only one of them or an error depending on how your mv works.
For the script-sperts: I don't think fname=`basename $filename` does anything useful, it's functionally equivalent to fname=filename.
Working on a script and will post later ...
Edit:
Oops! The Advanced Bash Scripting Guide already noted defects in the above scripts and gives this improvement
Code:
# The above script will not work on filenames containing blanks or newlines.
# Stephane Chazelas therefore suggests the following alternative:
for filename in * # Not necessary to use basename,
# since "*" won't return any file containing "/".
do n=`echo "$filename/" | tr '[:upper:]' '[:lower:]'`
# POSIX char set notation.
# Slash added so that trailing newlines are not
# removed by command substitution.
# Variable substitution:
n=${n%/} # Removes trailing slash, added above, from filename.
[[ $filename == $n ]] || mv "$filename" "$n"
# Checks if filename already lowercase.
done
exit $?
If you start with Foo, FOO and foo then this improved script still means you will end up with only one of them or an error depending on how your mv works.
Best
Charles