Last active
December 27, 2018 14:58
-
-
Save alpercalisir/752f75781d721baf31d5741ff1824611 to your computer and use it in GitHub Desktop.
Change the name of the sub directories such that they will be aligned with their parent directory name. Used for VGGFace 2 Dataset.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import os.path | |
from os.path import basename | |
rootDir = 'img' | |
for dirName, subdirList, fileList in os.walk(rootDir): | |
#print('Found directory: %s' % dirName) | |
for fname in fileList: | |
base = basename(dirName) | |
location=dirName+'/'+fname | |
#print ('\t%s' % fname) | |
print(base+'_'+fname) | |
os.rename(dirName+"/"+fname, base+'_'+fname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment