I woke up today and asked myself, why not write a small python script. Here it is:
- #!/usr/bin/env python
- import re
- import os
- # regex matching the file name blablaqwe123456.txt
- regex = '^s_Entrepreneurship_Corner_Podcasts_(\S+)(\d\d)(\d\d)(\d\d)\.(txt)$'
- # prepare the regex
- r = re.compile(regex)
- # list files in the current directory
- all = os.listdir('.')
- for fname in all:
- m = r.match(fname)
- if m:
- # extract the different parts from the old name
- name = m.group(1)
- year = "20" + m.group(2)
- month = m.group(3)
- day = m.group(4)
- ext = m.group(5)
- # create the new name
- newfname = year + "-" + month + "-" + day + "-" + name + "." + ext
- # rename the file
- print "renaming " + fname + " to " + newfname + "..."
- os.rename(fname, newfname)
Feel free to use it!