python-scripts/scripts/04_rename_with_slice.py

15 lines
422 B
Python
Raw Normal View History

2014-05-02 23:52:52 +02:00
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 as e:
print(e)
2014-05-02 23:52:52 +02:00
else:
print("Renamed {} to {}".format(file, new_file_name))