-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrenumberer.py
More file actions
35 lines (30 loc) · 940 Bytes
/
renumberer.py
File metadata and controls
35 lines (30 loc) · 940 Bytes
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
import os
def is_int(s):
try:
int(s)
return True
except ValueError:
return False
os.chdir(os.path.dirname(__file__))
state = ""
to_numb = 0
from_numb = int(input("From where: "))
raise_numb = int(input("With how many: "))
dir = sorted(os.listdir(), key=len)
for button in reversed(dir):
if button[0:6] == "button" and is_int(button[6]):
if button[-5] == "f":
to_numb = -8
state = "off"
else:
to_numb = -7
state = "on"
button_numb = int(button[6:to_numb])
new_numb = button_numb + raise_numb
if button_numb >= from_numb:
os.rename(button, 'button{}_{}.png'.format(new_numb, state))
print('Renaming button{}_{}.png to button{}_{}.png'.format(button_numb, state, new_numb, state))
input('Donezo')
# while F in os.listdir():
# os.rename(F, 'button{}_{}.png'.format(i, state))
# i+=1