我尝试根据模式重命名文件,然后将它们移动到新文件夹
$ltmpPath = "D:somepath\Temp\"
$ldstPath = "D:\OtherPath\Folder\"
get-childItem $ltmpPath | rename-item -newname { $_.name -replace "(^[a-z]+)(\d\d\d\d)\.pdf", "sg`${2}14.pdf"
get-childItem $ltmpPath | Where-Object { $_.name -match "(^sg)(\d\d\d\d\d\d)\.pdf"} | move-item -Destination $ldstPath -WhatIf
所有这一切都是将每个文件复制到文件D:\ OtherPath \ Folder而不是D:\ OtherPath \ Folder \ sgxxxxxx.pdf。
如果:执行操作"移动文件"目标"项目:D:somepath \ Temp \ sg311014.pdf目的地:D:\ OtherPath \ Folder \"。