Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4247932
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:10:44+00:00 2026-05-21T04:10:44+00:00

How can I rename each file in folder: pattern is: (first part of file

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:10:45+00:00Added an answer on May 21, 2026 at 4:10 am

    Try this:

    Get-ChildItem | Where {!$_.PSIsContainer} | 
        Rename-Item -NewName {$_ -replace '([^.]+)\.(\d)(\w)', '$1.0$2$3'} -wh
    

    Or if you have more than nine files:

    gci | ? {!$_.PSIsContainer -and $_.Name -match '([^.]+\.)(\d)(\w+)'} |  
      rni -NewName {$matches[1] + ("{0:00}" -f [int]$matches[2]) + $matches[3]} -wh
    

    The second example uses aliases to shorten the command (easier for typing). gci is the alias for Get-ChildItem, ? is the alias for Where-Object and rni is the alias for Rename-Item. The -wh invokes the WhatIf functionality 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 -wh to actually execute it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I rename a virtual directory (i.e., change the Virtual Path name) in
Can I safely rename the cygdrive folder? Also, I would like to add other
I want to rename each file that ends in .log, but I have similar
I need to monitor a folder and its subdirectories for any file manipulations (add/remove/rename).
I of course know that I can rename the init arg for an attribute
How can I rename all hidden directories under the current directory in DOS? I've
I can run RENAME TABLE student TO student_new ; The command is same and
Given a zipfile with an unknown directory, how can I rename or move that
Is there an automatic way I can use to rename a pylons controller? If
How can I use SMO to rename the physical .mdf .ndf .ldf files. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.