-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchangeName.py
More file actions
45 lines (40 loc) · 1.45 KB
/
changeName.py
File metadata and controls
45 lines (40 loc) · 1.45 KB
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
40
41
42
43
44
45
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2019-01-29 17:44:19
# @Author : Your Name (you@example.org)
# @Link : http://example.org
# @Version : $Id$
import os
def find_file(filedir):
folders = os.listdir(filedir)
for name in folders:
curname = os.path.join(filedir,name)
if os.path.isfile(curname):
# 文件名中满足的条件,可以在后面使用and filedir.find(dir_tag)来满足文件目录的要求
if name.find('.jpg') > 0:#and name.find(file_tag2) < 0
filename_list.append(curname)
else:
find_file(curname)
# filedir='/home/aaron/slambook/slambook-master/picmatch/alldata'
filedir ='/aaron/slambook/slambook-master/picmatch/test/alltest'
filename_list=[]
find_file(filedir)
for index,item in enumerate(filename_list):
filename=item.split("/")[-1]
os.rename(item,os.path.join(filedir,str(index+442)+'.jpg'))
# traindir=os.path.join(filedir,'train')
# testdir=os.path.join(filedir,'test')
# isExists=os.path.exists(traindir)
# if not isExists:
# os.mkdir(traindir)
# os.mkdir(testdir)
# testcount=0
# for index,item in enumerate(filename_list):
# filename=item.split("/")[-1]
# # filename=filename.split('.')[0]
# filename = filename[:-4]
# if index%3==0:
# os.rename(item,os.path.join(traindir,str(index/3)+'.jpg'))
# else:
# os.rename(item,os.path.join(testdir,str(testcount)+'.jpg'))
# testcount=testcount+1