powershell-重命名文件并移动

重命名文件并移动

例如文件jinwei.txt先修改为jinwei+随机码.txt(例如:jinwei23.txt)

然后Move到to路径

$from="\\10.XX.XX\from\*.*"
$to="C:\to\"

$a =get-random -maximum 100
$a =[string]$a+".TXT"

Get-ChildItem -Path $from  |
    Rename-Item -NewName {$_.Name -replace ".txt",$a} -PassThru |
        Move-Item -Destination $to -Force
posted @ 2021-08-04 12:54  JinweiChang  阅读(170)  评论(0编辑  收藏  举报