windows 比较windows中的2个目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19201955/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Compare 2 directories in windows
提问by user2369634
I need to compare 2 folders "A" and "B" and get the list of files and folders newly added or modified.
我需要比较 2 个文件夹“A”和“B”并获取新添加或修改的文件和文件夹列表。
I tried using Winmerge software but it is not comparing the files present inside the internal folders(so i have to point to each internal folder manually and have to compare)
我尝试使用 Winmerge 软件,但它没有比较内部文件夹中存在的文件(因此我必须手动指向每个内部文件夹并进行比较)
Is there any way to achieve this.
有什么办法可以做到这一点。
回答by gringo_dave
For Windows you can use this solution.
对于 Windows,您可以使用此解决方案。
Here's the right way to do it, without the external downloads. It looks like a lot at first, but once you've done it, it's very easy.
It works in all Windows versions from 7 back to 95. For our example assume that you're comparing two directories named 'A' and 'B'.
- run cmd.exe to get a command prompt. (In Windows 7, the powershell won't work for this, FYI.) Then do it again, so that you have two of them open next to each other.
- in each window go to the directories that you want to compare. (Using 'cd' commands. If you're not comfortable with this, then you should probably go with the external utilities, unless you want to learn command prompt stuff.)
- type 'dir /b > A.txt' into one window and 'dir /b > B.txt' into the other. You'll now have two text files that list the contents of each directory. The /b flag means bare, which strips the directory listing down to file names only.
- move B.txt into the same folder as A.txt.
- type 'fc A.txt B.txt'. The command 'fc' means file compare. This will spit out a list of the differences between the two files, with an extra line of text above and below each difference, so you know where they are. For more options on how the output is formatted, type 'fc /?' at the prompt. You can also pipe the differences into another file by using something like 'fc A.txt B.txt > differences.txt'.
Have fun.
这是正确的方法,无需外部下载。一开始看起来很多,但是一旦你完成了,就很容易了。
它适用于从 7 到 95 的所有 Windows 版本。对于我们的示例,假设您正在比较名为“A”和“B”的两个目录。
- 运行 cmd.exe 以获取命令提示符。(在 Windows 7 中,powershell 对此不起作用,仅供参考。)然后再做一次,这样您就可以将其中两个并排打开。
- 在每个窗口中转到要比较的目录。(使用 'cd' 命令。如果您对此不满意,那么您可能应该使用外部实用程序,除非您想学习命令提示符。)
- 在一个窗口中键入“dir /b > A.txt”,在另一个窗口中键入“dir /b > B.txt”。您现在将有两个文本文件,列出每个目录的内容。/b 标志表示裸,它将目录列表剥离为仅文件名。
- 将 B.txt 移动到与 A.txt 相同的文件夹中。
- 输入'fc A.txt B.txt'。命令 'fc' 表示文件比较。这将列出两个文件之间的差异列表,每个差异的上方和下方都有一行额外的文本,以便您知道它们的位置。有关如何格式化输出的更多选项,请键入“fc /?” 在提示下。您还可以使用“fc A.txt B.txt > Differences.txt”之类的内容将差异传送到另一个文件中。
玩得开心。
回答by AlfredD
We have been using Beyond Compare for years and it's quite useful. You can see which files are identical, which files are in folder "A" only and which files are in folder "B" only, and files that are different (for those files you can see what specific modifications have been made).
我们多年来一直在使用 Beyond Compare,它非常有用。您可以看到哪些文件是相同的,哪些文件仅在文件夹“A”中,哪些文件仅在文件夹“B”中,以及不同的文件(对于这些文件,您可以看到进行了哪些特定修改)。
回答by Vinodh Kumar
Check this manual http://manual.winmerge.org/Compare_dirs.html#Compare_dirs_startingprovides more info how to include all files in the folders recursively.
检查本手册http://manual.winmerge.org/Compare_dirs.html#Compare_dirs_starting提供了更多信息如何递归地包含文件夹中的所有文件。
Also you can try beyond compare tool for diff.
您也可以尝试超越比较工具的差异。