To do a search and replace I recommend using this:
find . -type f | xargs perl -pi -e "s/foo/mypackage/g"
You can use the pattern to seach and replace recursively all files: where foo is the text you want to replace and mypackage is the replacement text.
Most linux distributions contain a perl script called rename you can use to rename the files and directories.
ie:
rename "s/foo/mypackage/"