我有一个脚本,它将具有特定扩展名的文件从源目录移动到目标目录。复制项目不包括PowerShell中源目录的子文件夹文件
我的源目录的样子:
FILESFOLDER
File1.td
File2.td
SUBFOLDER
File3.td
File4.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
来自一个配置文件,只有当我声明它为0123时才有效
该脚本可以工作,但不会将文件从子文件夹复制到目标。目的地只有File1和File2。
我的Copy-Item命令有什么问题?
是否要将子文件夹中的文件与子文件夹本身一起复制?或者你只想要这些文件? –
我想要在目的地中具有完全相同的结构,所以子文件夹和文件 –