我想将文件从一个位置复制到另一个位置,并且这些文件应该与源文件位于同一文件夹中。当我使用以下脚本时,它会复制文件,但不会复制源文件夹中的文件夹。有什么建议么?
$a=Get-ChildItem C:\temp\_pdf_list -recurse | Where-Object {$_.name -like "*pdf" -and $_.name -notlike "*prth*"}
$a
foreach($x in $a) {copy-item -path $x.FullName "c:\temp\_pdfs_ck" -whatif}
请注意,目标路径不会按照我需要的方式将文件放入名为 1001 的子文件夹中。
输出:
What if: Performing operation "Copy File" on Target "Item: C:\temp\_pdf_list\1001\10010001.pdf Destination: C:\temp\_pdfs_ck\10010001.pdf".