🌶️
Hi Ardit
My solution: https://pastebin.com/1C4a2fx8
I used sys.argv
So when you run the file you have to specify the directory the files are in e.g.:
$ python main.py files
Another more generic way if we want to change the names of all files in the dir:
for root, dirs, files in os.walk(sys.argv[1]):
for file in files:
filepath = os.path.join(root, file)
name, ext = os.path.splitext(filepath)
os.rename(filepath, f'{name}-{today}{ext}')
Hi Ardit
My solution: https://pastebin.com/1C4a2fx8
I used sys.argv
So when you run the file you have to specify the directory the files are in e.g.:
$ python main.py files
Another more generic way if we want to change the names of all files in the dir:
for root, dirs, files in os.walk(sys.argv[1]):
for file in files:
filepath = os.path.join(root, file)
name, ext = os.path.splitext(filepath)
os.rename(filepath, f'{name}-{today}{ext}')