-1
I want to change/change the name of a set of images.
I have the python code that does this, the problem is that it generates as follows "123image.jpg" and that wanted "image123.jpg". How to adjust this in code?
import os
path = '/Users/gustavo/projects/dump/tf_files/locate_vaccancies/vaccancy'
files = os.listdir(path)
for index, file in enumerate(files):
os.rename(os.path.join(path, file), os.path.join(path, 'vaccancy'.join([str(index), '.jpg'])))
Thanks, I’ll try it.
– GustavoSevero
This is Imonferrari speaking. I circled my python file and it pointed out syntax error here: [move(file, f'g{i}.jpg') for i, file in enumerate(files)] Syntaxerror: invalid syntax In single quotes after jpg
– GustavoSevero
Which version of python do you use? Maybe this solves the problem in your case:
[move(arquivo, 'imagem'+str(i)+'.jpg') for i, arquivo in enumerate(arquivos)]
– lmonferrari