如何创建显示文件名称及其内容的日志文件

时间:2017-01-18 21:51:54

标签: csv batch-file

我有一个BAT文件,它将特定文件夹中所有CSV文件的文件名显示在日志文件中。它还显示这些CSV文件的内容。

File1 Name
File2 Name
File1 Content
File2 Content

输出的方式是:

File1 Name / File1 Content
File2 Name / File2 Content

有没有办法让它显示为:

split

另外一个问题,“日志”文件似乎保存为.txt而不是.LOG。我该如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

这个怎么样?

for /f %%a in ('dir /b *.csv') do for /f "usebackq tokens=*" %%b in (`type %%a`) do echo %%a / %%b >> MM.LOG

答案 1 :(得分:0)

type command,当使用*type *.csv > MM.LOG 2>&1 等通配符时,会在 STDERR 流中返回每个类型文件的名称或路径,对于 STDOUT 流可能是redirected

> MM.LOG

术语1> MM.LOG,相当于1,将流2>&1 STDOUT )中的数据重定向到日志文件。 2将流1 STDERR )的数据重定向到与流MM.LOG相同的目标,因此html * { padding:0; margin:0; } @font-face { font-family: ITC Franklin; src: url("ITC_Franklin_Book.otf"); } h1, p, h3 { font-family: ITC Franklin; } #results img{ margin-left: 3%; margin-top: 6%; } #wrapper{ width: 100%; height: 100%; } header{ z-index: 1; } header h1{ margin-top: 1.5%; margin-left: 25.5%; } .knopje { width: 50%; height: 10%; border: medium solid grey; margin-left: 25%; } /* MENU */ #nav li { background-color: white; height: 50%; line-height: 40px; list-style: outside none none; margin-left: 26%; padding-left: 35px; padding-right: 35px; position: relative; } /* body */ body { line-height: 1.5em; max-width:100%; background-image:url("image/background.jpg"); background-size: 100%; } /* Header */ header { background: none repeat scroll 0 0 white; border-radius: 15px; display: inline-block; float: left; height: 50px; margin: 2.5% 4.5% 3.5% 10%; width: 82.5%; } header img { display: inline; margin-left: -3%; margin-top: -2%; max-width: 100%; position: absolute; width: 9%; z-index: 1; } /* Actions screen LINKS */ div #linkerdiv{ background: none repeat scroll 0 0 white; border-radius: 30px; display: inline-block; float: left; height: 500px; margin-left: 7.5%; margin-top: 0.5%; margin-bottom: 3.5%; width: 40%; } input #poll{ margin-left: 5%; } #linkerdiv img{ width:45%; height:40%; margin-left: 3%; margin-top: 5%; max-width: 100%; z-index: 1; } #linkerdiv p{ margin-left: 5%; margin-top: 1%; margin-bottom: 1%; width: 90%; font-size: 11pt; } #linkerdiv li{ font-family: ITC Franklin; margin-left: 5%; list-style: none; } h3 { margin-left: 5%; } textarea{ border-radius: 30px; max-width: 90%; width: 90%; margin-left: 5%; margin-top: 1%; } /* Presentatoren div rechts */ div #rechterdiv{ background: none repeat scroll 0 0 white; border-radius: 30px; font-family: ITC Franklin; display: inline-block; float: right; height: 500px; margin-right: 7.5%; margin-top: 0.5%; margin-bottom: 3.5%; width: 40%; } #rechterdiv h2 { margin-left: 5%; margin-top: 3%; margin-bottom: 1%; width: 90%; font-size: 13pt; } #rechterdiv p{ margin-left: 5%; margin-top: 1%; margin-bottom: 1%; width: 90%; font-size: 11pt; } /*BREAKPOINT1*/ /*BREAKPOINT 2*/ @media screen and (max-width:40em) { html, body { width: 100%; overflow-x: hidden; } header h1{ font-size: 1.5em; } div #linkerdiv { background: none repeat scroll 0 0 white; border-radius: 30px; height: 500px; margin-left: 7.5%; margin-top: 0.5%; margin-bottom: 3.5%; width: 87%; } div #rechterdiv { background: none repeat scroll 0 0 white; border-radius: 30px; float: right; height: 500px; margin-bottom: 3.5%; margin-right: 5.5%; margin-top: 0.5%; width: 87%; } #w3-display-container mySlides { z-index: 5; } #w3-btn-floating w3-hover-dark-grey w3-display-right { z-index: 10; } #w3-btn-floating w3-hover-dark-grey w3-display-left { z-index: 10; } header { background: none repeat scroll 0 0 white; border-radius: 15px; display: inline-block; float: left; height: 75px; margin: 2.5% 4.5% 3.5% 10%; width: 82.5%; } header img { display: inline; margin-left: -7%; margin-top: -2%; max-width: 100%; position: absolute; width: 25%; } }