I've got a lot of .txt files with names starting with "read" that I want to rename. I want them to be named with the first line in the file. I'm a really lousy programmer, but I've given it a go and now I'm stuck.
import os
for filename in os.listdir("."):
if filename.startswith("read"):
for line in filename:
os.rename(filename, line)
At the moment the script does nothing and even if it worked I'm pretty sure the files wouldn't keep their extensions.
Any help would be greatly appreciated, thank you.