Fee*_*ety 5 powershell file-copying
我希望将文件从目录结构复制到新文件夹.我不是要保留文件结构,只是获取文件.文件结构可以有嵌套文件夹,但是名为'old'的文件夹中的任何内容我都不想移动.
我做了几次尝试,但我的PowerShell知识非常有限.
示例是当前文件结构的存在位置:
Get-ChildItem -Path "C:\Example\*" -include "*.txt -Recurse |% {Copy-Item $_.fullname "C:\Destination\"}
Run Code Online (Sandbox Code Playgroud)
这给了我所有我想要的文件,包括我不想要的所有文件.我不想包含"旧"文件夹中的任何文件.要注意:有多个"旧"文件夹.我试过--exclude,但看起来它只与文件名有关,我不知道如何在路径名上排除 - 同时仍然复制文件.
有帮助吗?
这个怎么样:
C:\Example*" -include "*.txt -Recurse |
?{$_.fullname -notmatch '\\old\\'}|
% {Copy-Item $_.fullname "C:\Destination\"}
Run Code Online (Sandbox Code Playgroud)
排除在其路径中任何位置具有'\ old \'的所有内容.
| 归档时间: |
|
| 查看次数: |
9992 次 |
| 最近记录: |