Hi!
I'm about to rename a hole bunch of files in different folders and want to use Python to do it. The problem is that I want to keep parts of the file name from the old file and insert it into the new file in another location.
for example:
old file: abcXXabc
new file: XXdefghi
Where the XX is the part I want to keep; always numbers. XX is'nt always on the same location in the old file. Any suggestions on how to do this?
I'm a newb when it comes to Python but heard it was great to use for these types of problems and maybe i can become more skilld afterwards!
this is what I got so far..
directory = '.'
for file in os.listdir('directory'):
re.search('([0-9]+)', file).group(1)
if '&' in file :
os.rename(file, file.replace('abcabc', 'defghi'))
Greatly appreciate it! /MCl