so I've been using the following code to change the file name of all of the files in a specific folder.
import os
[os.rename(f,f.replace('20180810','2018_08_10')) for f in os.listdir()]
The issue I'm having is that whenever I use this code, I have to save a copy of it and paste it in the folder where the files are present. I'd like to be able to have a general code where I can specify the path without having to be in that folder. I tried the following but for some reason it says it can't find the file:
path = 'E:/CSVFILES/20180808/'
[os.rename(f,f.replace('20180810','2018_08_10')) for f in os.listdir(path)]
If I run os.listdir(path), it runs fine and it displays the files in the folder, so I'm not sure why it's not working.
Thanks!