我有一個腳本,它將具有特定擴展名的文件從源目錄移動到目標目錄。複製項目不包括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命令有什麼問題?
是否要將子文件夾中的文件與子文件夾本身一起復制?或者你只想要這些文件? –
我想要在目的地中具有完全相同的結構,所以子文件夾和文件 –