我怎样才能比较两个子目录与目录,看看有什么区别?
在Linux下:
$ diff -r /first/directory /second/directory
在Windows下:你可能会更好的下载并安装WinMerge
> WinMerge /rc:\first\folder c:\second\folder
中号
超越比较是一个很好的商业工具,30美元左右。 在windows下运行,有一个eval版本。 http://www.scootersoftware.com/
我在Ubuntu上使用meld – 它有一个很好的目录比较选项。
在Windows上,我相信windiff可以,但是Winmerge是我工作的首选工具。 它是开源的,并且比较两套目录树的工作非常干净。
编辑:哎呀,被马吕斯殴打
Windows的DiffMerge显示差异,包括窗口中的子文件夹。 也有一个便携式版本,但快速search显示此下载: http : //www.softpedia.com/get/System/File-Management/SourceGear-DiffMerge.shtml
我使用Powershell中的Compare-Objects cmdlet编写了这个代码:
#set the directories $firstdirectory = Read-Host "What is the first directory you wish to compare?" $seconddirectory = Read-Host "What is the second directory you wish to compare?" #Check if the user wants to compare subdirectories $recursivesearch = Read-Host "Do you wish to compare subdirectories? Please enter yes or no." If ($recursivesearch -eq "yes") #get the contents { $firstdirectorycontents = @(Get-ChildItem $firstdirectory -Recurse) $seconddirectorycontents = @(Get-ChildItem $seconddirectory -Recurse ) } else { $firstdirectorycontents = @(Get-ChildItem $firstdirectory) $seconddirectorycontents = @(Get-ChildItem $seconddirectory) } #compare the objects and handle errors if ($firstdirectorycontents.Count -eq 0 ) { Write-Host "No files were found in the first directory, the directories cannot be compared." } elseif ($seconddirectorycontents.Count -eq 0) { Write-Host "No files were found in the second directory, the directories cannot be compared." } else { try { Compare-Object -ReferenceObject $firstdirectorycontents -DifferenceObject $seconddirectorycontents } catch {"Another error occured."} }