| 1 |
import os, sys |
| 2 |
from os import path |
| 3 |
import shutil |
| 4 |
|
| 5 |
cwd = os.getcwd() |
| 6 |
|
| 7 |
old_name = sys.argv[1] |
| 8 |
new_name = sys.argv[2] |
| 9 |
folder_name = sys.argv[3] |
| 10 |
|
| 11 |
old_namepath = str(cwd + old_name) |
| 12 |
new_namepath = str(cwd + new_name) |
| 13 |
filepath = str(cwd) + str(folder_name) + new_name |
| 14 |
|
| 15 |
|
| 16 |
files_to_remove = [new_name] |
| 17 |
for Dfile in files_to_remove: |
| 18 |
try: |
| 19 |
os.remove(cwd + Dfile) |
| •20 |
except OSError: |
| 21 |
pass |
| 22 |
|
| 23 |
|
| 24 |
os.rename(old_namepath,new_namepath) |
| 25 |
|
| 26 |
|
| 27 |
shutil.move(new_namepath, filepath) |
| 28 |
|