8000 Create rename_with_slice.py · janusnic/python-scripts@f6a1a26 · GitHub
[go: up one dir, main page]

Skip to content

Commit f6a1a26

Browse files
committed
Create rename_with_slice.py
1 parent 1008c04 commit f6a1a26

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

rename_with_slice.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import os
2+
import glob
3+
4+
os.chdir("/Users/mikeherman/repos/bugs/se-platform/se/core/permissions")
5+
for file in glob.glob("*.json"):
6+
file_name = os.path.splitext(file)[0]
7+
extension = os.path.splitext(file)[1]
8+
new_file_name = file_name[:-6] + extension
9+
try:
10+
os.rename(file, new_file_name)
11+
except OSError, e:
12+
print e
13+
else:
14+
print "Renamed {} to {}".format(file, new_file_name)

0 commit comments

Comments
 (0)
0