Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 交换两个文本文件的内容_Batch File - Fatal编程技术网

Batch file 交换两个文本文件的内容

Batch file 交换两个文本文件的内容,batch-file,Batch File,我正在处理一个批处理文件,我有两个名为 a.txt包含“hello”和b.txt包含“hi” 如何交换两个txt文件的内容,使a.txt包含“hi”和b.txt包含“hello” 编辑: @echo off ren %1.txt tempfile ren %2.txt %1.txt ren tempfile %2.txt 将其另存为swap.bat并按如下方式使用: swap a.txt b.txt 没有使用ren还有其他可能的解决方案吗?因为在我的例子中,要交换的不仅仅是两个文件,而且重命

我正在处理一个批处理文件,我有两个名为
a.txt
包含“hello”和
b.txt
包含“hi”

如何交换两个txt文件的内容,使
a.txt
包含“hi”和
b.txt
包含“hello”

编辑

@echo off
ren %1.txt tempfile
ren %2.txt %1.txt
ren tempfile %2.txt
将其另存为
swap.bat
并按如下方式使用:

swap a.txt b.txt

没有使用ren还有其他可能的解决方案吗?因为在我的例子中,要交换的不仅仅是两个文件,而且重命名所有这些文件需要花费大量的时间。如果你不能给出准确的细节,那么你通常会得到不符合你实际需要的解决方案。
swap a.txt b.txt