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 have a bunch of files named YYYYDDMM_prep888 and I want to rename them to YYYYMMDD_prep888, just exchanging DD for MM. I'd appreciate some help. Thanks.

share|improve this question
What have you attempted yourself or do you just want some one to do your work? – Dave Nov 12 '13 at 13:26

Assuming that your files have a regular form you can use a similar batch file:

@echo off
setlocal enableextensions enabledelayedexpansion

FOR /F %%A IN ('dir /b *_prep888') DO (
    rem split the data
    set file=%%A
    set pre=!file:~0,4!
    set dd=!file:~4,2!
    set mm=!file:~6,2!
    set post=!file:~8,8!
    set new_name=!pre!!mm!!dd!!post!

    ECHO renaming !file! into !new_name!

    ren !file! !new_name!
share|improve this answer

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.