Quote:So below is the program that I am using to change files with European (DD-MM-YYYY) style date to American (MM-DD-YYYY)
you could just use datetime to convert the date.
from datetime import datetime time = '13-01-2017' def convert(t): date_format = "%d-%m-%Y" convert_to_format = "%m-%d-%Y" return datetime.strptime(t, date_format).date().strftime(convert_to_format) print(convert(time))
Output:01-13-2017
Quote:For example, ab12-10-2010test.txt works but ab22-10-2010test.txt does not work.then just extract the date portion of the string, convert it, then reinsert the old portion wrapped around the new date format and rename it. The input could be anything even
2-1-2017
and it will still output 01-02-2017
Recommended Tutorials: