none
Adding line of text to all files in a floder

    Question

  • Hey 

    So i am making some addon scenery for a flight simulator. The scenery i am making is by downloading hundreds of satellite pictures which are then put as the ground texture. When they are downloaded it makes 1 .ter file for each photo and i want to add a line of code to that file. It is a file that can be opened with any text editing software so that should not be a problem. I guess the issue is the amount of the files and that i wont be able to use the filename since there are so many of them. Does anyone know how this could be done?

    Thank you in advance

    Karl

    Wednesday, January 18, 2017 9:15 PM

Answers

  • I think that it can be done with command-line features of Operating System. Put the additional lines in some file, a.txt for example. Then create a batch file a.cmd having this contents:

        FOR %%f IN (*.ter) DO type a.txt >> "%%f"

    Then run a.cmd.

    If required, backup the original files.


    • Edited by Viorel_MVP Thursday, January 19, 2017 4:08 PM
    • Marked as answer by karl120699 Thursday, January 19, 2017 9:52 PM
    Thursday, January 19, 2017 6:14 AM

All replies

  • Hi Karl, 

    Welcome to MSDN forum. 

    Would you mind telling what kind of project you built in Visual Studio?

    Best regards, 

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 19, 2017 5:18 AM
  • I think that it can be done with command-line features of Operating System. Put the additional lines in some file, a.txt for example. Then create a batch file a.cmd having this contents:

        FOR %%f IN (*.ter) DO type a.txt >> "%%f"

    Then run a.cmd.

    If required, backup the original files.


    • Edited by Viorel_MVP Thursday, January 19, 2017 4:08 PM
    • Marked as answer by karl120699 Thursday, January 19, 2017 9:52 PM
    Thursday, January 19, 2017 6:14 AM
  • Hi Fletcher

    I only have basic knowledge on programming so most of the stuff i have done was very simple projects taking an input and throwing something back at you in the console depending on that. I have never done an actual project before.

    Thanks for helping.

    Karl

    Thursday, January 19, 2017 2:14 PM