How to copy folder structure under another directory?

后端 未结 3 1361
日久生厌
日久生厌 2021-02-15 23:51

I have some questions related to copying a folder structure. In fact, I need to do a conversion of pdf files to text files. Hence I have such a folder structure for the place wh

3条回答
  •  孤独总比滥情好
    2021-02-16 00:34

    A minor tweak to your code for skipping pdf files:

    for root, dirs, files in os.walk('.', topdown=False):
        for name in files:
            if name.find(".pdf") >=0: continue
            with open("D:/g/"+ ,mode="w") as newfile:
                newfile.write(c.convert_pdf_to_txt(os.path.join(root, name)))
    

提交回复
热议问题