Create rename_with_slice.py

This commit is contained in:
Michael Herman 2014-05-02 16:52:52 -05:00
parent 1008c04851
commit f6a1a2688f

14
rename_with_slice.py Normal file
View 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)