Finally you’ll find some technical details in this blog as some insights might be useful to others.
The following snippets were used to rename a project under version control (Subversion). The renaming was performed in two steps. The first step was the renaming of all occurrences of the appropriate String in the source files. This was performed by a simple find/sed combination:
find . -type d \( -name .svn \) -prune -o -exec sed -i 's/oldName/newName/g' {} \;
The second step involved the renaming of source files within source control (Subversion). The following Python script was used. By changing the svn move command to an normal mv the changes can be tested without committing the files directly to the repository:
#!/usr/bin/python
import osimport sysimport pysvn
# List of replacementsd = {}d["oldName"] = "newName"rootdir = '.'client = pysvn.Client()
def changeName(file, root): for k, v in d.iteritems(): if file.replace(k, v) != file: client.move(os.path.join(root, file), os.path.join(root, file.replace(k, v))) client.checkin(rootdir, 'Moved ' + file + ' to ' + file.replace(k, v))# os.rename(os.path.join(root, file), os.path.join(root, file.replace(k, v))) return 1 return 0
def renameAll(): for root, subFolders, files in os.walk(rootdir, True): if '.svn' in subFolders: subFolders.remove('.svn')
for folder in subFolders: renamed = changeName(folder, root) if renamed == 1: return renamed
for file in files: renamed = changeName(file, root) if renamed == 1: return renamed return 0
def main(): done = 1; rootdir = sys.argv[1] client.update(rootdir) while done == 1: done = renameAll()
if __name__ == '__main__': main()