Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a series of folders on a Windows server which are a numerical sequence 92001, 92002, etc. and I need to add a '0'at the start of all these folders.

Rather than do this tedious task manually for the next two weeks, I was hoping to create a batch file to get it done much faster. How can I do this?

share|improve this question
How's that batch creation going? Getting held up at a particular spot? There's no question in your question. – Wutnaut May 19 '14 at 15:36
The answer below got everything the way I wanted it. Thank you for checking in. – Eric May 20 '14 at 12:55
up vote 2 down vote accepted
for /D %%f in (*) do rename "%%f" "0%%f"
share|improve this answer
@Moses - The code is only renaming folders because of the FOR /D option, so there is no need to worry about the batch file renaming itself. – dbenham May 19 '14 at 18:43
@dbenham Sorry I didn't notice the /D switch, correct you are! – Moses May 19 '14 at 18:53
Thank you for the answer. I had to take out the extra % signs to run it from a command line, but otherwise it worked great! – Eric May 20 '14 at 12:54
Yup, you need the double %% only when running from a .bat file – RJFalconer May 21 '14 at 8:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.