I am a complete beginner in python. I need to rename a bunch of files with dates in the name. The names all look like:
front 7.25.16
left 7.25.16
right 7.25.16
I would like them to start with the date rather then front, left, or right, so that front 7.25.16
becomes 7.25.16 front
.
I have tried using regular expressions and os.walk and I have run into troubles with both. Right now I am just trying to print the file names to prove os.walk is working. Right now my code looks like this:
import re, shutil, os
K = re.compile(r"(\d+.\d+.\d+)")
RE_Date = K.search("front 7.25.16")
for root, dirs, filenames in os.walk("path"):
for filename in filenames:
print ("the filename is: " + filename)
print ("")
Any advice would be greatly appreciated.