Create rename_with_slice.py
This commit is contained in:
parent
1008c04851
commit
f6a1a2688f
14
rename_with_slice.py
Normal file
14
rename_with_slice.py
Normal file
@ -0,0 +1,14 @@
|
||||
import os
|
||||
import glob
|
||||
|
||||
os.chdir("/Users/mikeherman/repos/bugs/se-platform/se/core/permissions")
|
||||
for file in glob.glob("*.json"):
|
||||
file_name = os.path.splitext(file)[0]
|
||||
extension = os.path.splitext(file)[1]
|
||||
new_file_name = file_name[:-6] + extension
|
||||
try:
|
||||
os.rename(file, new_file_name)
|
||||
except OSError, e:
|
||||
print e
|
||||
else:
|
||||
print "Renamed {} to {}".format(file, new_file_name)
|
Loading…
Reference in New Issue
Block a user