-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path16.py
More file actions
23 lines (18 loc) · 745 Bytes
/
Copy path16.py
File metadata and controls
23 lines (18 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'''
> Date Created: 10/08/2025
> Author: Ishaan Rastogi
> Purpose: Write a python program to rename a file to "new.txt".
> Operating System: This is only for Windows OS, it may or may not work on other OS
> Program Status: 100% Working
'''
# Approach - Make copy of a file and rename it to "new.txt" and delete the original file.
with open (r"I:\My Drive\CS 100\Py-Lang\Code With Harry\9. File IO\poems_copy.txt", "r") as f:
content = f.read()
with open (r"I:\My Drive\CS 100\Py-Lang\Code With Harry\9. File IO\new.txt", "w") as f:
f.write(content)
import os # Operating System module
os.remove(r"I:\My Drive\CS 100\Py-Lang\Code With Harry\9. File IO\poems_copy.txt")
'''
Terminal - Ctrl + Shift + `
> python "path to the file"
'''