我有一个脚本,它将具有特定扩展名的文件从源目录移动到目标目录。
我的源目录如下所示:
文件夹
文件1.td
文件2.td
子文件夹
文件3.td
文件4.td
我的脚本很短,看起来像:
if(!(Test-Path $SourceDirPath) -or !(Test-Path $DestinationDirPath))
{
Write-Host "The source- or destination path is incorrect, please check "
break
}else
{
Write-Host "Success"
Copy-Item -path $SourceDirPath -Filter "*$extension" -Destination $DestinationDirPath -Recurse
}
我不得不提到,$SourceDirPath
它来自一个配置文件,只有当我将它声明为C:\FILESFOLDER\*
该脚本有效,但不会将文件从子文件夹复制到目标。目的地只有 File1 和 File2。
我的 Copy-Item 命令有什么问题?