-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathch_name.py
More file actions
64 lines (40 loc) · 1.17 KB
/
ch_name.py
File metadata and controls
64 lines (40 loc) · 1.17 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
import shutil
from pathlib import Path
#global name_file
#name_file = "coco.names"
#data1 = open(name_file, 'a')
global path
path = "laneclosed1/"
global search1
search1 = "a"
file_list = os.listdir(path)
file_list_py = [file for file in file_list if file.endswith(".txt")]
search_num = 0
print ("file_list: {}".format(file_list_py))
for test1 in file_list_py:
try:
with open(path + test1) as file:
label_dir = path + test1
label_dir2 = label_dir.replace(".txt", search1 + ".txt")
data_file = Path(label_dir)
data_file.rename(label_dir2)
label_dir = label_dir2
except:
print("error in " + test1 + "\n")
continue
file_list = os.listdir(path)
file_list_py = [file for file in file_list if file.endswith(".jpg")]
search_num = 0
print ("file_list: {}".format(file_list_py))
for test1 in file_list_py:
try:
with open(path + test1) as file:
label_dir = path + test1
label_dir2 = label_dir.replace(".jpg",search1 + ".jpg")
data_file = Path(label_dir)
data_file.rename(label_dir2)
label_dir = label_dir2
except:
print("error in " + test1 + "\n")
continue