Entering edit mode
8.0 years ago
ahmedakhokhar
▴
150
I would have a folder of 8000 files with names
Phy000CVIC_YEAST.raw.fasta
Phy000CVID_YEAST.raw.fasta
Another file (ID.txt) contains ids as
Phy000CVKM YAL001C
Phy000CVKL YAL002W
And I am trying to change files names with IDs in file(ID.txt) with python, what I am doing so far
f = os.listdir('/Users/admin/Desktop/folder')
for f in f:
if f.endswith('.clean.fasta'):
ef=f.split('_')
with open('ID.txt') as id:
for i in id:
i=i.split()
if ef[0]==i[0]:
print(os.rename(f, i[1]))
I am getting the following error
None
None
Traceback (most recent call last):
File "<stdin>", line 8, in <module>
OSError: [Errno 2] No such file or directory
Please guide, where and what is wrong ?
(PS: only two files get renamed out of 8000plus)