Trying to index and search for a file within 8K files and 2K folders..
尝试索引和搜索8K文件和2K文件夹中的文件..
Is there a simple Powershell script that can move all files from folders and/or subfolders into one main folder?
是否有一个简单的Powershell脚本可以将文件夹和/或子文件夹中的所有文件移动到一个主文件夹中?
don't need to delete the empty folders but would help.
不需要删除空文件夹但会有所帮助。
1 个解决方案
#1
20
The fourth example under help -Examples Move-Item
is close to what you need. To move all files under the source
directory to the dest
directory you can do this:
帮助-Examples Move-Item下的第四个示例接近您所需要的。要将源目录下的所有文件移动到dest目录,您可以执行以下操作:
Get-ChildItem -Path source -Recurse -File | Move-Item -Destination dest
If you want to clear out the empty directories afterwards, you can use a similar command:
如果要在之后清除空目录,可以使用类似的命令:
Get-ChildItem -Path source -Recurse -Directory | Remove-Item
#1
20
The fourth example under help -Examples Move-Item
is close to what you need. To move all files under the source
directory to the dest
directory you can do this:
帮助-Examples Move-Item下的第四个示例接近您所需要的。要将源目录下的所有文件移动到dest目录,您可以执行以下操作:
Get-ChildItem -Path source -Recurse -File | Move-Item -Destination dest
If you want to clear out the empty directories afterwards, you can use a similar command:
如果要在之后清除空目录,可以使用类似的命令:
Get-ChildItem -Path source -Recurse -Directory | Remove-Item