Debian Codegraph @

scripts/rename_move.py

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
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 # Removing old file
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 # Renaming new file
24 os.rename(old_namepath,new_namepath)
25
26 # Moving new file
27 shutil.move(new_namepath, filepath)
28