In: Computer Science
IN PYTHON:
Write a program that asks the user for a path to a directory, then updates the names of all the files in the directory that contain the word draft to instead say final
EX: "term paper (draft).txt" would be renamed "term paper (final).txt"
BONUS (5pts): for any .txt file that your program changes the name of, have your program add a line of text that states "Edited on " followed by the current date to the end of the text in the file that it is editing.





EDITABLE CODE:
from os import rename, listdir
import datetime
#draft process
replace = "draft"
#asking for user input for directory
direct_path=raw_input("please Enter directory of path : ")
filename = listdir(direct_path)
#iteration values
for fname11 in filename:
#check the condition
if replace in fname11:
#open file
with open(fname,"a") as f1:
#write function
f1.write('Edited on : ')
f1.write(str(datetime.datetime.now()))
f1.close()
#rename file name
rename(fname11, fname11.replace(replace, 'final', 1))