Try adding print statements to both functions. "None" means that no pattern match was found.
def find_name():
folder = "C:/Users/Sam/Desktop"
for filename in os.walk(folder).next()[2]:
print "testing filename", filename
if pattern.match(filename):
print "find_name returning", filename
return filename
def main():
newname = str(duration) + ".txt"
filename = find_name()
print "filename returned is", filename
## comment the next line for now, until you get
## the program fixed
## os.rename(filename, newname)
Then see the article here, especially the os.path.normpath() http://pythonconquerstheuniverse.blogspot.com/2008/06/python-gotcha-raw-strings-and.html (This question has been asked so many times that it seems no one will answer it anymore.)