I was wondering how to get my script to return to the beginning if “Y” or “y” is pressed? I tried making it a function, then calling that function if the “IF” statement returns “Y” or “y”, but that does not work. Any help would be appreciated, thanks.
import os
path = os.getcwd() #Working/active directory
filenames = os.listdir(path)
print "**Rename Active Directory File(s)**\n"
CurName = raw_input ("Current Name: ")
NewName = raw_input ("New Name: ")`
def Ren():
for filename in filenames:
os.rename(os.path.join(path, filename), os.path.join(path, filename.replace(CurName, NewName)))
Final = raw_input('\nPress Enter to Exit or \"Y" to Restart!:\n ')
if Final == 'Y' or 'y':
Ren()