gpt4 book ai didi

powershell - 如何在Powershell中排除一个子文件夹的同时复制文件夹

转载 作者:行者123 更新时间:2023-12-03 00:11:18 26 4
gpt4 key购买 nike

我对PowerShell非常陌生,我试图将不包含某些子文件夹的文件夹复制到其他文件夹。我在下面包含了我的代码。希望这是有道理的。

$from = 'C:\erp\github\bliss_'
$to = 'C:\erp\websites\bitesize'
$ExcludeFolders = @(".git","DHTMLX","mflasite","nbproject",".gitignore")

Get-ChildItem -Path $from -Recurse -Exclude $ExcludeFolders | Copy-Item $_.fullname -Destination $from -Force -Exclude $ExcludeFolders

最佳答案

因此-Exclude限定了Path。您需要输入一个可以识别的模式:

$ExcludeFolders = @(
'*\.git\*'
'*\DHTMLX\*'
'*\mflasite\*'
'*\nbproject\*'
'*\.gitignore'
)
-Exclude <String[]>
Specifies, as a string array, an item or items that this cmdlet excludes in
the operation. The value of this parameter qualifies the Path parameter. Enter
a path element or pattern, such as *.txt. Wildcards are permitted.

Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false

关于powershell - 如何在Powershell中排除一个子文件夹的同时复制文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48098699/

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