如何将文本追加到多个文件 [英] How to append text to multiple files

查看:126
本文介绍了如何将文本追加到多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是一个程序员,但我是一个研究者,我需要修改一些文件。
我公司拥有一批具有位于C * .MOL扩展名的文本文件:\abc\目录。我需要追加包含以下文字M END在此列表中的每个文件行。我试过下面在C#中,但没有任何结果:

I am not a programmer, but I am a researcher and I need to modify some files. I have a number of text files with *.mol extension located in c:\abc\ directory . I need to append line containing following text "M END" to each file in this list. I tried following in C# but without any result:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            StreamWriter sw = new StreamWriter("c:\\abc\\*.mol", true); 
            sw.WriteLine("M  END"); 
            sw.Close();   

        }
    }
}

请,建议的解决方案。

感谢您!

推荐答案

你是满足于此oneliner,你可以把任何DOS批处理文件(.bat):

Would you be satisfied with this oneliner that you can put in any DOS batch (.bat) file:

FOR %%I IN (c:\abc\*.mol) DO ECHO M  END>>%%I

这篇关于如何将文本追加到多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆