use*_*651 4 powershell powershell-3.0
我有一堆文件,其名称以数字开头,可能在两个数字之一后包含空格和短划线,然后有时(有时不会)在我想要保留的名称的第一个字母字符之前有一个空格,即:
2-01 Dazed And Confused.txt(我想将其重命名为Dazed And Confused.txt)
要么
02 - Uncle Salty.txt(我想将其重命名为Uncle Salty.txt)
要么
02-The Night Before.txt(我想重命名为The Night Before.txt)
该Move-Item和Rename-Item的cmdlet可以直接从管道接受源和使用脚本块提供了一个新的名字:
dir | Move-Item -Destination { $_.Name -replace '^([0-9\-\s]*)' }
Run Code Online (Sandbox Code Playgroud)
要么
dir | Rename-Item -NewName { $_.Name -replace '^([0-9\-\s]*)' }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8686 次 |
| 最近记录: |