forked from f1tenth/f1tenth_racetracks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rename.py
55 lines (38 loc) · 1.4 KB
/
rename.py
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
# importing os module
import os
directory = os.getcwd()
for count, mapname in enumerate(os.listdir(directory)):
directory2 = directory+"/"+mapname
if mapname == '.DS_Store':
continue
if mapname == 'LICENSE':
continue
if mapname == 'README.md':
continue
if mapname == 'rename.py':
continue
if mapname == 'convert.py':
continue
if mapname == '.gitignore':
continue
for count2, filename2 in enumerate(os.listdir(directory2)):
file_name, file_ext = os.path.splitext(filename2)
if file_ext == '.txt':
old = directory2 + '/' + filename2
new = directory2 + '/' + mapname + '_DonkeySim_waypoints.txt'
os.renames(old,new)
elif file_ext == '.csv':
if file_name == mapname + '_map_waypoints':
old = directory2 + '/' + filename2
new = directory2 + '/' + mapname + '_centerline.csv'
os.renames(old, new)
elif file_name == mapname + '_raceline_newconv':
old = directory2 + '/' + filename2
new = directory2 + '/' + mapname + '_raceline.csv'
os.renames(old, new)
elif file_ext == '.pgm':
removefile = directory2 + '/' + filename2
os.remove(removefile)
# rename() function will
# rename all the files
#os.rename(src, dst)