Hi,
I would like to rename files (jpg's ones) using a text file containing the
new names...
Below is the code that doesn't work :
*****
#!/usr/bin/python
#-*- coding: utf-8 -*-
from os import listdir, getcwd, rename
import re
list_names=['new_name1','ne w_name2']
list_files = listdir(getcwd( ))
filtre = re.compile("jpg $", re.IGNORECASE)
list_jpg = filter(filtre.s earch, list_files)
#strip all element of list list_jpg
list_jpg_strip=[]
for nom in list_jpg:
#print nom.strip()
list_jpg_strip. append(nom.stri p())
#let's rename :
i=0
while i <= len(list_jpg_st rip):
rename(list_jpg _strip[i],list_names[i])
i=i+1
****
The error message is :
File "ecm.py", line 17, in <module>
rename(list_jpg _strip[i],list_names[i])
OSError: [Errno 2] No such file or directory
and all files exists, I checked it hundred times ! :-s
Do you have a clue ?
Thanks a lot.
Rémi.