Recursively compare two directories to ensure they have the same files and subdirectories

后端 未结 11 1307
猫巷女王i
猫巷女王i 2020-12-23 20:49

From what I observe filecmp.dircmp is recursive, but inadequate for my needs, at least in py2. I want to compare two directories and all their contained files. Do

11条回答
  •  醉酒成梦
    2020-12-23 21:41

    dircmp can be recursive: see report_full_closure.

    As far as I know dircmp does not offer a directory comparison function. It would be very easy to write your own, though; use left_only and right_only on dircmp to check that the files in the directories are the same and then recurse on the subdirs attribute.

提交回复
热议问题