gpt4 book ai didi

Powershell - 比较文件夹内容

转载 作者:行者123 更新时间:2023-12-04 17:37:17 31 4
gpt4 key购买 nike

我有下面的代码比较两个文件夹并输出每个文件夹不同的文件,有没有办法让它输出子文件夹中文件的完整文件/文件夹路径?

干杯

 # Create varaibles to store folder paths - pass to Strings... 
param([string]$argFolderA,[string]$argFolderB)

# Set variables for folder
$FolderA = Get-ChildItem -Recurse -path $argFolderA
$FolderB = Get-ChildItem -Recurse -path $argFolderB

# Compare the contents and output the files different within each folder.
Compare-Object -ReferenceObject $FolderA -DifferenceObject $FolderB >> C:\CmpOut.txt

最佳答案

像这样使用比较对象的 Passthrough 标志:

Compare-Object -ReferenceObject $FolderA -DifferenceObject $FolderB -Passthru | % {$_.FullName}  >> C:\CmpOut.txt

关于Powershell - 比较文件夹内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14319945/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com