Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have one .txt file with some text that I want to append to all .txt files in a folder.

Can anyone explain to me how to do it?

share|improve this question
1  
Do you want to replace the existing content of the other files, or do you want to append the text to the existing file contents? (Or anything else?) –  Arjan Mar 16 '13 at 11:37
    
I want to append the text to the existing file contents... –  Noober Mar 16 '13 at 11:48
add comment

1 Answer

up vote 2 down vote accepted

I suggest to rename the file which should be appended to append_me (or anything without .txt extension), then you can use a FOR loop over *.txt files in a batch file append.bat:

@echo off
for %%a in (*.txt) do type append_me >> %%a
  • @ suppresses the printing of the follwing command line prior to execution
  • echo off does the same for all following commands
  • %%a defines a variable, which takes (one after another) the *.txt file names (*)
  • type displays the file content (Linux analogon is cat)
  • >> appends that content to the current file (%%a)

(*) If you use that command directly on the command line, use only %a; see for /? for the complete syntax of for loops.

share|improve this answer
    
Thanks for fast answer... It's working... –  Noober Mar 16 '13 at 13:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.