From 06cd2ea8c6cb8d1ad255a7bec69a18e181e300d8 Mon Sep 17 00:00:00 2001
From: izabel <izabel>
Date: Mon, 25 Jan 2010 15:09:26 +0000
Subject: [PATCH] [SE-189] script renaming files and directories

SVN: 14431
---
 screening/source/python/rename.py | 39 +++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100755 screening/source/python/rename.py

diff --git a/screening/source/python/rename.py b/screening/source/python/rename.py
new file mode 100755
index 00000000000..5aa2fd57af2
--- /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!"
-- 
GitLab