0

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.

  • What have you attempted yourself or do you just want some one to do your work? – Dave Nov 12 '13 at 13:26
0

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!
)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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