我想比较两台不同计算机上的文件夹。
我正在使用 BitTorrent Sync 在两台计算机之间同步当前 260 GB 的数据:一台 Windows 7 台式电脑和一台 Windows 8.1 笔记本电脑。所有这些数据都位于一个目录层次结构中,根文件夹名为“stuff”。
我注意到台式电脑报告的文件大小和文件数量与笔记本电脑报告的文件大小和文件数量存在明显差异。
现在我想使用一个工具来比较台式电脑的“stuff”目录和笔记本电脑的“stuff”目录,以便找出丢失和更改的文件和文件夹。两台计算机无法通过网络访问彼此的文件系统,但可以通过 USB 闪存驱动器将一台计算机的文件夹结果传输到另一台计算机。
答案1
答案2
@harrymc 关于使用 md5deep/hashdeep 的提示对我来说很有效。以下提供了一种使用 hashdeep64 比较两台计算机之间的目录层次结构的方法:
# computer A == computer on which a hashlist.txt for all files in someFileHierarchysTopDirectoryOnComputerA is generated
# computer B == computer on which computer A's generated hashlist.txt is used to compare files. Computer B generates a hashcompareresult.txt
# On computer A, create a hashlist.txt for some file hierarchy located in directory someFileHierarchysTopDirectoryOnComputerA. hashlist.txt will be placed in someFileHierarchysTopDirectoryOnComputerA's parent directory.
cd someFileHierarchysTopDirectoryOnComputerA
hashdeep64 -c md5 -r -l -e -vvv * | tee ../hashlist.txt
# this probably will take some time to finish.
# Now copy the generated hashlist.txt onto computer B's "someFileHierarchysTopDirectoryOnComputerB/.." directory. Then on computer B,
cd someFileHierarchysTopDirectoryOnComputerB
hashdeep64 -c md5 -r -l -k ../hashlist.txt -a -e -vvv * | tee ../hashcompareresult.txt
# hashdeep's -w, -W, -x, and -X modes don't seem to report errors on missing and additional files. Therefore using -a mode.
# Above command will have generated a file hashcompareresult.txt in someFileHierarchysTopDirectoryOnComputerB's parent directory.
# Now filter the created hashcompareresult.txt for mismatches:
cat ../hashcompareresult.txt | grep -E ": No match|: Known file not used"
# The resulting output shows files that
# * exist only on computer A, or
# * exist only on computer B, or
# * exist on both computers at the same location but have different MD5 hashes.
# Depending on the use case, above command probably will report some false positive files and directories, e.g. desktop.ini, Thumbs.db, .DS_Store, __MACOSX, .sync, and .SyncArchive .
# It may be adequate to filter out these file system entries, e.g. with
# cat ../hashcompareresult.txt | grep -E ": No match|: Known file not used" | grep -v -E "desktop.ini|Thumbs.db|.DS_Store|__MACOSX|.sync|.SyncArchive"