Skip to content

Commit f05742f

Browse files
authored
used os library to get file names and rename the files
1 parent 6fa1e6d commit f05742f

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

rename_couple_of_files.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import os
2+
3+
def rename_file():
4+
#get the list of all the file names from the target folder
5+
list_name = os.listdir("C:\Users\gautam\Desktop\prank")
6+
print(list_name)
7+
os.chdir("C:\Users\gautam\Desktop\prank")
8+
cd = os.getcwd()
9+
print(cd)
10+
#rename the file names to remove the numerics
11+
for file_name in list_name:
12+
os.rename(file_name,file_name.translate(None,"1234567890"))
13+
14+
15+
rename_file()

0 commit comments

Comments
 (0)