diff --git a/screening/source/python/rename.py b/screening/source/python/rename.py new file mode 100755 index 0000000000000000000000000000000000000000..5aa2fd57af2124036ffb047a0f835260303a7071 --- /dev/null +++ b/screening/source/python/rename.py @@ -0,0 +1,39 @@ +#!/usr/bin/python + +# +# Creates a list of 'mv' commands renaming files and directories containing _YF_ to '_HIV1_'. +# +# author: Izabela Adamczyk + +import os +import shutil + +currentDir = os.getcwd() + '/' + +# Rename files +for (dir, subdirs, files) in os.walk('.'): + for file in files: + if file.find('_YF_') != -1: + fileToBeChanged = currentDir + dir + '/' + file + targetFilename = currentDir + dir + '/' + file.replace('_YF_', '_HIV1_') + command = "mv %s %s" % (fileToBeChanged, targetFilename) + print "echo", command + print command + # shutil.move(fileToBeChanged, targetFilename) + print "" +print "echo Files: Done!" + +# Rename directories +for (dir, subdirs, files) in os.walk('.'): + for subdir in subdirs: + if subdir.find('_YF_') != -1: + dirToBeChanged = currentDir + dir + '/' + subdir + targetFilename = currentDir + dir + '/' + subdir.replace('_YF_', '_HIV1_') + command = "mv %s %s" % (dirToBeChanged, targetFilename) + print "echo", command + print command + #shutil.move(dirToBeChanged, targetFilename) + print "" +print "echo Directories: Done!" + +print "echo Done!"