2.txt
I have a list of 20 file names, like ['file1.txt', 'file2.txt', ...]. I want to write a Python script to concatenate these files into a new file. I could open each file by f = open(...), read line by line by calling f.readline(), and write each line into that new file. It doesn't seem very "elegant" to me, especially the part where I have to read/write line by line.
2.txt
For example, consider a directory containing the following files:1.gif, 2.txt, card.gif and a subdirectory subwhich contains only the file 3.txt. glob() will producethe following results. Notice how any leading components of the path arepreserved.
This will copy the files "in1.txt", "in2.txt", and "in3.txt" to a file called "Combined.txt". (The Combined.txt file is automatically created by the Copy command. If Combined.txt previously existed, it is overwritten by the command.) The Copy command supports wildcards, too, so if your file names follow a standard format, you could even do it this way: 041b061a72