如果我有一些名为 pippo_yyyymmdd.txt、pluto_yyyymmdd.txt 等的文件,如何删除时间戳并将文件重命名为 pippo.txt、pluto.txt ?
尝试一下,它会删除所有下划线后跟 8 位数字。这是 basicmidea,它不处理最终具有相同名称的文件:
Get-ChildItem *.txt |
Where {$_.Name -match '_\d{8}\.txt' } |
Rename-Item -NewName {$_.Name -replace '_\d{8}'}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7576 次 |
| 最近记录: |