I have 100 of folder where in each folder I have another folder with same name and inside that folder there is a .txt file which I want to extract and merge all the txt files into a new folder.

Please help me with a script in python

1 Answer 1


Go to the root folder of 100 sub folders and find all of the .txt files, copy them into the new folder ~/tests:

find ./ -type f -name "*.txt" -exec cp "{}" ~/tests/ \;

  • thanks it worked...now if i want to convert all these txt files into csv format ....can I do that?
    – heilo
    Commented Aug 30, 2022 at 3:16
  • sure, but have to see the contents of txt files. Please create one new question.
    – Hans Chen
    Commented Aug 30, 2022 at 8:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .