Jumper
1
I have the following files named: original, original (1), etc (n+1)
I want to remove the space after the file name and the number in the parentheses and replace it with -1
Expected output:
original, original-1 and so on and so forth
what I come up with so far is :
dir | Rename-Item -NewName {$_.name -replace "(\d)$", ""}
But not sure how to implement the replace part
I found this here but not able to replicate the results
OJL
2
File Rename with Customizable Increasing Number
Dir original* | ForEach-Object -begin { $count=0 } -process { rename-item $_ -NewName “original$count”; $count++ }
Hi Oussama-jlassi,
Thanks for the help. The only thing I added to make it work is .jpg
Dir original*.jpg | ForEach-Object -begin { $count=0 } -process { rename-item $_ -NewName “original$count.jpg”; $count++ }
OJL
4
That’s great!
you are welcome