使用powershell将不同文件夹中的各种文件保存到一个文件夹中
Saving various files in different folders into one single folder using powershell
我这里有 3 个文件夹和 3 个文件。
每个文件夹中都有一个 csv 文件,我想将它们全部保存到目标文件夹中,而不必打开每个文件夹并将文件拖放到目标文件夹中。
我试过了。
$destination = "C:\Desktop\Test"
$sourcefiles = get-childitem -recurse
foreach ($file in $sourcefiles)
{
Copy-Item $file.FullName -Destination "$destination$file.Name"
}
当我这样做时,我复制了文件夹,这真的很酷,但没有文件。
感谢任何帮助
正在寻找这样的东西...FileA 位于 TestA 中,FileB 位于 TestB 中。我有数百个这样的文件,我必须将它们保存到备份位置
您希望将文件夹及其内容复制到新目标,因此,只需定位文件夹然后使用 Copy-Item -Recurse
:
Get-ChildItem path\to\testfolders -Directory | Copy-Item -Destination "C:\Desktop\Test" -Recurse
我这里有 3 个文件夹和 3 个文件。
每个文件夹中都有一个 csv 文件,我想将它们全部保存到目标文件夹中,而不必打开每个文件夹并将文件拖放到目标文件夹中。
我试过了。
$destination = "C:\Desktop\Test"
$sourcefiles = get-childitem -recurse
foreach ($file in $sourcefiles)
{
Copy-Item $file.FullName -Destination "$destination$file.Name"
}
当我这样做时,我复制了文件夹,这真的很酷,但没有文件。
感谢任何帮助
正在寻找这样的东西...FileA 位于 TestA 中,FileB 位于 TestB 中。我有数百个这样的文件,我必须将它们保存到备份位置
您希望将文件夹及其内容复制到新目标,因此,只需定位文件夹然后使用 Copy-Item -Recurse
:
Get-ChildItem path\to\testfolders -Directory | Copy-Item -Destination "C:\Desktop\Test" -Recurse