How can I rename each file in folder:
pattern is: (first part of file name).digit_(endoffilename)
for example
a.1_f
b.2_f
c.3_g
I would like to replace it with
a.01_f
b.02_f
c.03_ g
…
Thanks for help
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try this:
Or if you have more than nine files:
The second example uses aliases to shorten the command (easier for typing).
gciis the alias forGet-ChildItem,?is the alias forWhere-Objectandrniis the alias forRename-Item. The-whinvokes theWhatIffunctionality where PowerShell will show you what it would do so you can twiddle with the command until you’re happy with what the results would be. Then remove the-whto actually execute it.