gpt4 book ai didi

powershell - 在Powershell中从递归中排除文件夹

转载 作者:行者123 更新时间:2023-12-03 01:17:39 25 4
gpt4 key购买 nike

我编写了以下脚本,将特定文件夹中的所有MP4文件移动到Root文件夹,但是我希望该脚本忽略一个名为“Camera”的特定文件夹。我正在使用exclude命令无济于事。有人可以帮忙吗?

$ignore = ("*Camera*");

Get-Childitem "C:\Root" -exclude $ignore -recurse -include *.mp4 | move-item -dest "C:\Root\"

最佳答案

-exclude是用来过滤文件名或扩展名的,我认为您不能使用它来过滤目录。
您可以尝试以下方法:

gci c:\root\*.mp4 -recurse |where {$_.fullname -notmatch "camera"}

关于powershell - 在Powershell中从递归中排除文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25602775/

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