从 Powershell 中的 Recurse 中排除文件夹 [英] Exclude folder from Recurse in Powershell

查看:55
本文介绍了从 Powershell 中的 Recurse 中排除文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've written the following script to move all MP4 file in a particular folder to the Root folder, however I want the script to ignore one particular folder called "Camera". I'm using the exclude command to no avail. Can anyone help?

$ignore = ("*Camera*");

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

推荐答案

-exclude 是过滤文件名或扩展名 我不认为你可以用它来过滤目录.你可以试试这个:

-exclude is to filter filename or extension I dont think you can use it to filter directories. You can try this :

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

这篇关于从 Powershell 中的 Recurse 中排除文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆