I have a folder with some files. The filenames have the format 123.createtable.txt, 124createtable.txt. I want to remove any whitespace in the filenames and also add a "." after the number sequence if not already present. I'm a little stuck on how to do the latter part.
import os
path = os.getcwd()
filenames = os.listdir(path) # Returns a list of the files of the directory given by path
for filename in filenames: # For each of the files
if "." not in filename:
filename.append (".")
os.rename(os.path.join(path, filename), os.path.join(path, filename.replace(' ', ''))) # Remove whitespace from filename
.ifstatement should be indented 4 more spaces.