【问题标题】:How do I rename a batch of files and move them to a new directory如何重命名一批文件并将它们移动到新目录
【发布时间】:2016-07-27 18:10:21
【问题描述】:

这是我迄今为止用来重命名/移动文件(单独)

Get-ChildItem | Rename-Item -NewName {$_.Name -replace '8369','Name'}

Move-Item -Force -Destination 'M:\Destination Test Folder\'

如何合并这两个任务或使用移动项目任务来移动和重命名文件?

我对 Powershell 还很陌生,所以我很感激任何帮助或见解

【问题讨论】:

    标签: powershell


    【解决方案1】:

    在目标参数中包含新文件名。

    Get-ChildItem | ForEach-Object{
        Move-Item $_ -Force -Destination ('M:\Destination Test Folder\' + ($_.Name -replace '8369','Name'))
    }
    

    【讨论】:

      猜你喜欢
      • 2012-02-26
      • 2014-12-19
      • 1970-01-01
      • 1970-01-01
      • 2022-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-26
      相关资源
      最近更新 更多