0

add few words in notepad

I have a batch of .txt files, each of them having different content. Now I would like to add few lines/words at the bottom end. if possible, when I drag a folder that contain huge amount of .txt into .py file, the additional words will added to bottom end of every .txt what coding should I looking for? any similar eg.? Tq

2nd Dec 2016, 3:54 AM
CJ009
CJ009 - avatar
2 Respuestas
+ 1
the .bat code for this for %f in (*.txt) do type "%f">> output.txt it takes all the .txt files in selected folder merge them and save the output as output.txt you will have to name .py .txt the bat doesnot delete other .py I understood that you want a code that merges the extra words of a text file with the other without doing it so this is code in windows batch script that merges two text files
2nd Dec 2016, 7:43 PM
Sandeep Chatterjee
0
If you want to append some text in python, you should use 'a' option of open() function. This code appends 'Appended text' to the end of every *.txt file in mydir directory: from os import listdir, path mydir = r'C:\text' for filename in filter(lambda x: x.endswith('.txt'), listdir(mydir)): with open(path.join(mydir, filename), 'a') as f: f.write('Appended text')
2nd Dec 2016, 5:55 PM
donkeyhot
donkeyhot - avatar