Reputation: 1
How to Rename multiple files that I have from 1.txt, 2.txt to something like 1_A.txt 2_A.txt I tried the code below but it didn't work
dir | rename-item -NewName {$_.name -replace ".txt ","_A.txt"}
Can someone give me some guidance how to do this, since I have 100 files to rename
Upvotes: 0
Views: 109
Reputation: 2565
You can use PowerShell:
Replace:
$_.name -replace ".txt ","_A.txt"
To:
($_.basename+'_A.txt')
ls *.txt | ? {ren $_.fullname -New ($_.basename+'_A.txt')}
Upvotes: 0