New learner. I have several txt files in a folder. I need to change the 'April' into 'APR'.
12 April 2019 Nmae's something Something.txt
13 April 2019 World's - as Countr something.txt
14 April 2019 Name and location.txt
15 APR 2019 Name then location,for something.txt
So it looks like this
12 APR 2019 Nmae's something Something.txt
13 APR 2019 World's - as Countr something.txt
14 APR 2019 Name and location.txt
15 APR 2019 Name then location,for something.txt
Here are links with the similar ones, but each of them are slightly different.
Python - Replace multiple characters in one file name
CHange multiple file name python
PYTHON - How to change one character in many file names within a directory
How to change multiple filenames in a directory using Python
I tried this:
import os
files = os.listdir('/home/runner/Final/foldername')
for f in files:
newname = f.replace('April', 'APR')
os.rename(f, newname)
But nothing changed, can I get some guide?