Windows cmd附加文件 [英] Windows cmd appending file
问题描述
我正在尝试搜索文件扩展名为.csv的目录。然后,一旦找到将内容附加到新的.csv文件。当我使用管道时,我能够看到.csv文件,但是当我将内容复制到新文件时,它不会使用最初位于.csv文件中的内容创建。有什么建议吗?
我尝试了什么:
这是什么我试过了
dirmydir| findstr / e .csv> newfile.csv
使用连接输出运算符>>:
dir mydir| findstr / e .csv>> newfile.csv
引用:是的我试过了,结果仍然相同。
你确定吗?因为当我尝试非常类似的东西时,它起作用:dir。 | findstr / e .txt>> newfile.txt如:
D:\Temp> cd testdir
D:\Temp \ testdir> dir
驱动器D中的体积为GriffData
体积序列号为4CA5-2F85
目录D:\ Temp \ testdir
01/11/2018 13 :36< DIR> 。
01/11/2018 13:36< DIR> ..
01/11/2018 13:36 652 x.txt
1个文件652字节
2 Dir(s)640,177,086,464字节免费
D :\ Temp \ testdir> dir。 | findstr / e .txt>> newfile.txt
D:\Temp \ testdir>输入newfile.txt
01/11/2018 13:47 0 newfile.txt
01/11/2018 13 :36 652 x.txt
D:\ Temp \ testdir> dir。 | findstr / e .txt>> newfile.txt
D:\Temp \ testdir>输入newfile.txt
01/11/2018 13:47 0 newfile.txt
01/11/2018 13 :36 652 x.txt
01/11/2018 13:47 92 newfile.txt
01/11/2018 13:36 652 x.txt
D:\ Temp\testdir>
cdmydir
FOR%i in(* .csv)DO type %i>> newfile.csv
I am trying to search a directory with a file extension of .csv. Then once found append the contents to a new .csv file. When I use the pipe I am able to see the .csv file but when I copy the contents to the new file it isn't created with the contents that were originally in the .csv file. Any suggestions?
What I have tried:
This is what I have tried
dir "mydir" | findstr /e .csv > newfile.csv
Use the concatenation output operator ">>":
dir "mydir" | findstr /e .csv >> newfile.csv
Quote:Yeah I tried that and still got the same result.
Are you sure? Because when I try something very similar it works:dir . | findstr /e .txt >> newfile.txtAs in:
D:\Temp>cd testdir D:\Temp\testdir>dir Volume in drive D is GriffData Volume Serial Number is 4CA5-2F85 Directory of D:\Temp\testdir 01/11/2018 13:36 <DIR> . 01/11/2018 13:36 <DIR> .. 01/11/2018 13:36 652 x.txt 1 File(s) 652 bytes 2 Dir(s) 640,177,086,464 bytes free D:\Temp\testdir>dir . | findstr /e .txt >> newfile.txt D:\Temp\testdir>type newfile.txt 01/11/2018 13:47 0 newfile.txt 01/11/2018 13:36 652 x.txt D:\Temp\testdir>dir . | findstr /e .txt >> newfile.txt D:\Temp\testdir>type newfile.txt 01/11/2018 13:47 0 newfile.txt 01/11/2018 13:36 652 x.txt 01/11/2018 13:47 92 newfile.txt 01/11/2018 13:36 652 x.txt D:\Temp\testdir>
cd "mydir" FOR %i in (*.csv) DO type %i >> newfile.csv
这篇关于Windows cmd附加文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!