passing file extension using external variable

Hi,
How can I modify the FILETYPE command ?
I want to provide the file extension, like txt, root .?

Thanks,

#!/bin/bash                                                                                                                                           

FROM=$1
TO=$2
FILETYPE=$3

for i in *$FILETYPE; do
    mv ${i} ${i/$FROM/$TO}
done

If I understand your intent correctly the following should work.

#!/bin/bash
FROM=$1 
TO=$2 
FILETYPE=$3 

find $FROM -name \*.$FILETYPE -exec mv {} $TO \;

Did not work..

laptop:~/Desktop/CMS/script/ShellScripts$ ./RenameTxt.sh File draft txt
find: `File': No such file or directory
laptop:~/Desktop/CMS/script/ShellScripts$ ls File*
File1.txt  File2.txt
laptop:~/Desktop/CMS/script/ShellScripts$ 

Provide full path to $FROM and $TO args.

Ah, I misunderstood your intent, I thought you wished to move everything under a directory tree...

#!/bin/bash

FROM=$1
TO=$2
EXTN=$3

for i in $FROM*.$EXTN ; do
    # echo mv $i ${i//$FROM/$TO}
    mv $i ${i//$FROM/$TO}
done

Should do it