“比较文件夹之间的文件和大小”的答案 https://knowledge.亚搏在线safe.com/questions/63134/compare-file-and-sizes-between-folders.html “比较文件夹之间的文件和大小”问题的最新答案 答案由markatsafe亚搏在线 https://knowledge.亚搏在线safe.com/answers/86673/view.html a rel="user" href="//www.baooytra.com/knowledge/users/9296/tosinbabs。html" nodeid="9296">@tosinbabs建议的工作空间@jdh看起来像这样(2018.1): FileChangeDetector.fmw < / > < / p > < / div > 格林威治时间2019年2月8日星期五20:12:29 markat亚搏在线safe 答案由隆 https://knowledge.亚搏在线safe.com/answers/63151/view.html

例如,使用这个脚本的PythonCaller从属性“_original_folder”和“_revised_folder”指定的两个文件夹路径中创建三个列表属性(见下文),并将列表添加到输入特性中。注意:这个脚本示例只是描述一种收集文件夹下所有文件大小的可能方法。它可能不是你最终目标的最佳选择。请适当修改。PythonCaller脚本示例类FileSizesComparer(object): def input(self, feature): #收集两个文件夹下所有文件的大小。{}, {} # {<相对文件路径>:& lt; size>} collectFileSizes (originalSizes feature.getAttribute (_original_folder)) collectFileSizes (revisedSizes, feature.getAttribute (_revised_folder)) originalPaths =组(originalSizes.keys ()) revisedPaths =组(revisedSizes.keys())对我来说,路径枚举(originalPaths & revisedPaths): sizeDiff = revisedSizes(路径)——originalSizes(路径)feature.setAttribute (“_unchanged {% d}。setattribute ('_unchanged{%d})setattribute ('_unchanged{%d}。setattribute ('_unchanged{%d}。setattribute ('_added{%d})。setattribute ('_added{%d})对于i,枚举中的路径(originalPaths - revisedPaths): features . setattribute ('_deleted{%d}。setattribute ('_deleted{%d})size' % i, originalSizes[path]) self.pyoutput(feature) # Helper function: Collect sizes of all files under a specified root folder. # Arguments # - pathToSize: dictionary {<relative file path> : <size>} # - absRoot: absolute path of the root folder # - relRoot: relative path of the root folder (empty by default) import os def collectFileSizes(pathToSize, absRoot, relRoot=''): for name in os.listdir(absRoot): absPath = os.path.join(absRoot, name) # absolute path of file or directory relPath = os.path.join(relRoot, name) # relative path of file or directory if not os.path.islink(absPath): if os.path.isfile(absPath): pathToSize[relPath] = os.path.getsize(absPath) else: collectFileSizes(pathToSize, absPath, relPath) # recursive call

"_unchanged{}" list contains the information on files existing under both original and revised folders. The list consists of these four members.

  • "filename" stores the relative file path.
  • "size_original" stores size of the file under the original folder.
  • "size_revised" stores size of the file under the revised folder.
  • "size_diff" stores the difference between the sizes of original file and revised file.

"_added{}" list contains the information (filename and size) on files existing only under revised folder.

"_deleted{}" list contains the information (filename and size) on files existing only under original folder.

格林威治时间2018年2月1日星期四06:01:44
答案由arthy https://knowledge.亚搏在线safe.com/answers/63147/view.html

Thanks @NathanAt亚搏在线Safehttps://knowledge.亚搏在线safe.com/answers/63136/view.html 目录和文件路径名Reader。它会抓取所有目录和/或文件的名称和属性(比如大小、所有者、创建日期等),以便进行比较。变形金刚像< a href = " https://docs.safe.com/fme/亚搏在线html/FME_Desktop_Documentation/FME_Transformers/Transformers/matcher.htm " target = "平等" >匹配器< / >、< a href = " https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/changedetector.htm " target = "平等" > ChangeDetector < / >,或者DuplicateFilter可以用来比较阅读后的结果。< br > < br >希望这有助于! Nathan < / p > < br > 格林尼治时间2018年1月31日星期三21:13:38 nathanat亚搏在线safe 答案由jdh https://knowledge.亚搏在线safe.com/answers/63135/view.html 并不是说你不能使用python,而是为什么不简单地使用目录和文件路径名读取器,将检索文件属性设置为Yes,然后加上一个更改检测器 格林尼治时间2018年1月31日星期三21:08:46 jdh