如何使用COPY命令附加到文件(How do I append to a file using th

2019-09-22 07:02发布

我运行Windows 7旗舰版64位,但我的经验可以追溯到DOS 3.0。

由于像DOS 3.1,你已经能够将文件添加到另一个与此使用COPY命令:

COPY FILE1+FILE2=FILE1

制作一个临时FILE3不必要的需要。

这是因为,只要你加入,你经常需要更新您的一个新的程序非常方便的命令CONFIG.SYSAUTOEXEC.BAT文件。

它也曾经是获得正确的顺序是importiant,否则你会最终空FILE1。

但今天,当我尝试过,它留下FILE1不变,当我颠倒了顺序,(可以理解)由FILE1的副本FILE2

有谁知道,如果它被替换为另一种方法,当这种变化发生了什么?

编辑:

我一直在做更多的测试,奇怪的是,即使上面的代码将无法正常工作,你仍然可以从窗台控制台复制并追加一条像这样一个现有的文件:

copy file1+con=file1
Type some text to append to file1
^Z ([CTRL]+Z the End Of File character)

如果我的Windows版本是搞砸了不知何故,我不知道。 任何机构可以复制我的发现?

编辑:

它适用于95/98 / ME / 2000 / XP / XP模式/ 7专业版64位/ 64位8。 所以我想,这不是一个7 Ultimate x64的问题,而是与我的机器的问题。

*叹气*

编辑:

最后编辑的,我保证。 :)

这是不是与我的机器的问题,它是与文件1的问题。 显然,当我第一次附加文件2到它,[Ctrl]键+ Z(EOF字符)从来没有得到覆盖,导致文件看起来像这样:

Original Data
Original Data
[EOF]
Appended Data
Appended Data
Appended Data

您可以自己从在命令提示符下面的实验重复这一点。 (其中^ Z是字符[CTRL] + Z)

在命令提示类型:

copy con file1
File One
^Z^Z

copy con file2
File Two
^Z

copy con file3
File Three
^Z

copy file1+file2=file1

copy file2+file3=file2

TYPE file1
TYPE file2

你会看见:

file1

File One

file2

File Two
File Three

您可以type file2 >> file1 ,或者使用串联的文件几乎任何其他方法,当你键入file1仍然只会出现包含File One 。 但如果您使用FIND "searchterm" file来解析文件它会告诉你什么是真正回事。 在这种情况下类型:

FIND " " file1

你会与奖励:

---------- FILE1
File One
→File Two

Answer 1:

Windows 8的x86的:

Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.

C:\Users\Nikos>echo foo>file1

C:\Users\Nikos>echo bar>file2

C:\Users\Nikos>copy /b file1 + file2 file1
file1
file2
        1 file(s) copied.

C:\Users\Nikos>type file1
foo
bar


Answer 2:

什么type file2 >> file1



Answer 3:

请确保你开始你从来没有试图拷贝过来的新鲜文件。
我刚刚发现我的(XP SP3) copy a+ba/b附加1ASUB )到文件的末尾,这使得事情后,从输出消失type (但more会表现出来)。 Copy /b a+ba的作品。



Answer 4:

@echo off

cls

type "file2.txt" >> "file1.txt"

exit


Answer 5:

回答:“ 我如何追加到一个文件使用COPY命令

警告 :如果你有希望通过COPY命令合并的文件列表,这很简单,但有可能破坏你的文件。

以危险方法

copy /b one + two + three -将追加的“二”和“三化”文件“一”的内容。 所以原来的“一”,现在已经在正确的顺序3个文件的内容。 如果在拷贝过程中出了问题,你有没有恢复原来的“一”,因为这将是腐败,你的数据将基本上消失的方式。 有几乎从来没有一个理由使用这种方式。

安全方式

copy /b one + two new_filename -将结合2个文件(你可以列出两个以上的课程),创建包含在正确的顺序“一”和“二”一new_filename,并留下原始文件完好无损。



Answer 6:

你有没有尝试copy /b file1 + file2 file1



Answer 7:

copy /b input1 + input2 output
del input1
ren output input1
也许这? :P



Answer 8:

C:\Users\Nikos>type file1
foo
bar

C:\Users\Nikos>copy file1+con=file1
file1
con
ihdui
ohisd
^Z
        1 file(s) copied.

C:\Users\Nikos>type file1
foo
bar
ihdui
ohisd


Answer 9:

等待! 还有更多! (Win7的临)

>ver

Microsoft Windows [Version 6.1.7601]

>copy file.a.txt + file.b.txt file.ab.txt
file.a.txt
1 file(s) copied

>copy fileA.txt + fileB.txt fileAB.txt
fileA.txt
fileB.txt
1 files(s) copied

暂且不论“1档(S)复制”的通知,它只是不喜欢古怪名字的文件。



Answer 10:

要复制到二进制文件...

将所有文件在同一文件夹如G:\Files

g:
cd Files
copy /B *.* TargetFilename.ext

.ext是文件所需的类型



Answer 11:

  1. 把所有的文件放在同一文件夹中。
  2. copy *.* ´target.ext'
  3. ????
  4. 利润!


文章来源: How do I append to a file using the COPY command