Off topic:up date the name of multiple files with list of IDs
2
1
Entering edit mode
8.1 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)

python basics Tool • 1.3k views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 2616 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6