import os
# with open("shijie_small_youtu_align_failed.txt","r") as face_file:
# for line in face_file.readlines():
# srcpath = line.strip().split("/")
# dstpath = ""
# num = 0
# for path in srcpath:
# if num == 5:
# path = "shijie_small_youtu_MTCNN_Alignment_Margin32"
# num += 1
# dstpath += path
# dstpath += "/"
# dstpath = dstpath[0:-1]
# print(line[0:-1])
# print(dstpath)
# cmd = "cp " + dstpath + " " + line[0:-1]
# os.system(cmd)
def findAllfile(path, allfile):
filelist = os.listdir(path)
for filename in filelist:
filepath = os.path.join(path, filename)
if os.path.isdir(filepath):
#print(filepath)
findAllfile(filepath, allfile)
else:
allfile.append(filepath)
return allfile
#mv /DATA/share/publicdata/stars/zhouxun/u=3942420804,889887287&fm=27&gp=0.jpg /DATA/share/publicdata/stars/zhouxun/7_zhouxun_8.jpg
clusterpath = "/DATA/share/publicdata/stars"
filelist = os.listdir(clusterpath)
floder_ID_index = 0
for filename in filelist:
filepath = os.path.join(clusterpath, filename)
if os.path.isdir(filepath):
print(filepath)
floder_ID_index += 1
print(floder_ID_index)
filepath_split = filepath.strip().split("/")
floder_ID = filepath_split[-1]
image_files = findAllfile(filepath,[])
#print(image_files)
face_index = 1
for image in image_files:
dstname = clusterpath + "/" + floder_ID + "/" + str(floder_ID_index) + "_" + floder_ID + "_" + str(face_index) + ".jpg"
image = "'" + image + "'"
print(image)
print(dstname)
face_index += 1
cmd = "mv " + image + " " + dstname
os.system(cmd)
还没有评论,来说两句吧...