Powershell比较两个文件夹的不同(powershell compress-archive分卷)万万没想到

随心笔谈2年前发布 admin
187 0 0

文章摘要

本文介绍了利用 shell 脚本实现批量复制文件的场景。文章内容分为三个部分:首先使用 `Get-ChildItem` 获取目标目录中的文件列表,并按文件名排序;然后复制这些文件到指定路径;最后使用 `Compare-Object` 比较两个文件列表,确保复制的准确性。整篇文章通过简洁的命令实现了高效的文件批量复制操作。

$list1=Get-ChildItem c:\Windows\system32 | Sort-Object -Property Name

$list2=Get-ChildItem \\server12\c$\windows\system32 | Sort-Object -Property Name

Compare-Object -ReferenceObject $list1 -DifferenceObject $list2 -Property Name |

  Sort-Object -Property Name

© 版权声明

相关文章