如何合并文本文件从所有子目录相同的名称? [英] How to merge text files with the same name from all subdirectories?

查看:537
本文介绍了如何合并文本文件从所有子目录相同的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件几个文件夹。文件可以具有相同的名称。我想连接文件到每个名字之一。先谢谢了。

I have several folders with files. Files can have the same names. I want to concatenate files into one of each name. Thanks in advance.

编辑:
对不起,你能告诉我该批处理文件吧。

I'm sorry, can you show me the batch file for it.

推荐答案

merge.bat

merge.bat

@echo off
# for every text file in
# the sub-dirs of current dir
for /r "." %%a in (*.txt) do (
   # filename without path and extension
   echo %%~na
   # read file and append it to file with 
   # the same name prefix in current dir
   type %%a >> %%~na-merged.txt
)

merge_all_in_one.bat

merge_all_in_one.bat

@echo off
for /r "." %%a in (*) do (
    type %%a >> all_merged.txt
)

这篇关于如何合并文本文件从所有子目录相同的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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