Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

rename files in folder python

import os
# Absolute path of a file
old_name = r"E:demosfiles
eportsdetails.txt"
new_name = r"E:demosfiles
eports
ew_details.txt"
# Renaming the file
os.rename(old_name, new_name)


# for multiple files
import os

for dirname in os.listdir("."):
	print((dirname[:-4]).zfill(6)+'.txt')
	os.rename(dirname, (dirname[:-4]).zfill(6)+'.txt')
 
PREVIOUS NEXT
Tagged: #rename #files #folder #python
ADD COMMENT
Topic
Name
5+9 =