我开发了一个PowerShell脚本,它的工作非常好。唯一的挑战是子文件夹中的文件没有移动到目的地。
get-childitem -Path "\\servername\location" |
where-object {$_.LastWriteTime -lt (get-date).AddDays(-31)} |
move-item -destination "C:\Dumps"
我无法进一步自定义脚本。
答案 0 :(得分:16)
不要浪费时间尝试在PowerShell中重新发明robocopy
。
robocopy \\servername\location C:\Dumps /e /mov /minage:31
答案 1 :(得分:11)
使用-Recurse
命令上的Get-ChildItem
选项来查看子文件夹中的文件,然后通过将集合管道传输到Move-Item
Get-ChildItem -Path "C:\Test" -Recurse |
Where-Object {$_.LastWriteTime -lt (Get-date).AddDays(-31)} |
Move-Item -destination "C:\Dumps"
以下是截图:
答案 2 :(得分:7)
简化上述内容
robocopy A:\ B:\ /MIR /minage:31
哪里
答:\是你的来源
B:\是你的目的地
答案 3 :(得分:0)
我需要一个快速的衬垫,将所有数据从一个驱动器移到另一个驱动器上。这对我很有用:
Get-ChildItem" E:" - 递送| Move-Item -Destination" G:"