Python Exercise 8: Solution + Tips | Python Tutorials For Absolute Beginners In Hindi #88

Code as described/written in the video

# Oh soldier Prettify my Folder

# path, dictionary file, format

# def soldier("C://", "harry.txt", "jpg")

import os
def soldier(path, file, format):
    i = 1
    files = os.listdir(path)
    with open(file) as f:
        filelist ="\n")

    for file in files:
        if file not in filelist:
            os.rename(file, file.capitalize())

        if os.path.splitext(file)[1] == format:
            os.rename(file, f"{i}{format}")
            i +=1

        r"C:\Users\Haris\PycharmProjects\PythonTuts\ext.txt", ".png" )

Be the first person to comment!