MOHAN KRISHNA

0 %
Mohan Krishna
Multimedia Professional
Ai & ML Researcher & Enthusiast
  • Residence:
    India
  • City:
    Vijayawada
  • Age:
    46
AI/ML Enthusiast. New Media Trainer, VFX Artist, Non Linear Video Editor, Graphic Designer, Sound Editor and iOS App Designer.
Telugu
English
Hindi
Tamil
Proficiency:
Graphic Design
Web Design
Video & VFX
Machine Learning
Artificial Intelligence
Digital Marketing
Areas of Interest:
Take a look at some of the things I love working on.
  • Non Linear Video Editing
  • Graphic Design
  • Web Design
  • Audio Editing
  • Content Management Systems
  • Python
  • Deep Learning
  • OpenCV
  • Image Classification

File Renaming In Python

October 29, 2022

Renaming:

# http://www.pillalamarri.in/python/file-renaming-in-python/
import os
for filename in os.listdir("/Users/User/Desktop/uni/change file names"):
	if filename.startswith("cheese_"):
		os.rename(filename, filename[7:])

Removing:

file_name = "hello23you.jpg"
print(file_name)
result = "".join([i for i in file_name if not i.isdigit()])
print(result)
# http://www.pillalamarri.in/python/file-renaming-in-python/

Project:

import os
for filename in os.listdir("/Users/User/Desktop/uni/change file names/workedOn"):
	path = os.getcwd()
	os.chdir("/Users/User/Desktop/uni/change file names/workedOn")
	result = "".join([i for i in filename if not i.isdigit()])
	os.rename(filename, result)
	os.chdir(path)
# http://www.pillalamarri.in/python/file-renaming-in-python/

Listing:

import os

x = os.listdir("/Users/User/Desktop/uni/change file names/workedOn")
print(x)
# http://www.pillalamarri.in/python/file-renaming-in-python/
Posted in PythonTags: