Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.