Replace Filename and text inside of directory

I have a directory that has directories that contain Dir-20111114-xyz and I want to change them to Dir-20111121-xyz.

Inside of Dir-20111114-xyz, I have a config.xml file that also contains the date that I need changed from 20111114 to 20111121

I have used sed to replace inside of file not sure how to handle renaming the directories.

Thank you.

You could use the mv command to rename files.

Please be more specific about you file names, what you wrote is confusing. Is the name of files actually "Dir-20111114-xyz"? Or, is part of that trying to show path and name, as in "\dir\2011114\xyz"?

the Directory name is actually "DIR-20111114-xyz" and there is 50 or so with "DIR-20111114-abc" "DIR-20111114-efg"
I want to keep the name intact except for the changing of the date.

OLDDATE=20111114
NEWDATE=yyyymmdd

for DIR in DIR-"${OLDDATE}"-*
do
        sed "s/${OLDDATE}/${NEWDATE}/g" < "${DIR}/config.xml" > "${DIR}/config.xml.new"
        #cat "${DIR}/config.xml.new" > "${DIR}/config.xml"
        # rm "${DIR}/config.xml.new"
        echo mv "${DIR}" "${DIR/${OLDDATE}/${NEWDATE}}"    
done

Remove the #'s and echoes once you've checked the output and the content of the config.xml.new files to make sure it's really done what you want.

There are several examples of q&a on batch renaming files: