Batch file 如何将2个txt制作成1个批次
我正在编写一个脚本,它将使用2个(或更多)txt并将其设置为1 这是我的密码:Batch file 如何将2个txt制作成1个批次,batch-file,cmd,Batch File,Cmd,我正在编写一个脚本,它将使用2个(或更多)txt并将其设置为1 这是我的密码: @echo off cd C:\Users\%username%\Desktop\ echo this is 1.txt > 1.txt echo this is 2.txt > 2.txt copy "C:\Users\%username%\Desktop\1.txt" >> source.txt copy "C:\Users\%username%\Desktop\2.txt" >&g
@echo off
cd C:\Users\%username%\Desktop\
echo this is 1.txt > 1.txt
echo this is 2.txt > 2.txt
copy "C:\Users\%username%\Desktop\1.txt" >> source.txt
copy "C:\Users\%username%\Desktop\2.txt" >> source.txt
我已经试过了:
echo "C:\Users\%username%\Desktop\1.txt" >> source.txt
echo "C:\Users\%username%\Desktop\2.txt" >> source.txt
但最终结果是:
无法将文件复制到自身。
已复制0个文件。
无法将文件复制到自身。
已复制0个文件
或
“C:\Users\%username%\Desktop\1.txt”
“C:\Users\%username%\Desktop\2.txt”
我希望你能帮我解决我的小问题:)
关于Jellex如果您试图将两个文件附加在一起,您可以使用:
copy "C:\Users\%username%\Desktop\1.txt" + "C:\Users\%username%\Desktop\2.txt" sorce.txt
或者,您可以使用:
type "C:\Users\%username%\Desktop\1.txt" >> sorce.txt
type "C:\Users\%username%\Desktop\2.txt" >> sorce.txt
以下是您的方法不起作用的原因:
copy a.txt>>b.txt
与将copy a.txt
的输出附加到sorce.txt
相同。由于copy a.txt
未指定目标文件,因此会出现错误echo“C:\Users\%username%\Desktop\1.txt”>>sorce.txt
与将echo“C:\Users\%username%\Desktop\1.txt”
的输出附加到sorce.txt
相同。所有的echo“C:\Users\%username%\Desktop\1.txt”
都是打印“C:\Users\%username%\Desktop\1.txt”
type 1.txt 2.txt > sorce.txt
然后验证内容:
type sorce.txt
复制用于复制文件,而不是对其内容进行编目