A Simple Script to remove all numbers from file names and renaming them
#Script to remove numbers from file names and rename them
import os
import string
def renameFiles():
files_list = os.listdir(r'/home/jayc/Python/prank/')
print(files_list)
saved_path = os.getcwd()
os.chdir(r'/home/jayc/Python/prank/')
print(os.getcwd())
for file_name in files_list:
os.rename(file_name, file_name.translate(file_name.maketrans('0123456789', ' ')))
os.chdir(saved_path)
renameFiles()
import os
import string
def renameFiles():
files_list = os.listdir(r'/home/jayc/Python/prank/')
print(files_list)
saved_path = os.getcwd()
os.chdir(r'/home/jayc/Python/prank/')
print(os.getcwd())
for file_name in files_list:
os.rename(file_name, file_name.translate(file_name.maketrans('0123456789', ' ')))
os.chdir(saved_path)
renameFiles()
Comments
Post a Comment