Preview:
import os

# Function to rename multiple files
def main():
    i = 0
    path = r"path_name"
    for filename in os.listdir(path):
        dst = str(i).zfill(4) + ".jpg"
        src = os.path.join(path, filename)
        dst = os.path.join(path, dst)
        os.rename(src, dst)
        i += 1
    return print("{} FILES COMPLETADOS".format(len(os.listdir(path))))


# Driver Code
if __name__ == "__main__":

    # Calling main() function
    main()
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter