Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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!"