-1

Hi i need the batch script to sort the existing date format of the files to the format of yyymmdd

Eg:-COBE018303_ej25102014

Output Should Be:-COBE018303_ej20141025

the same should be done for many more files but the first part of the file name should be the same(COBE018303_ej)

Kindly share the batch script for the above...

1 Answers1

0

Hi below is the Batch Script for my above question which i finally done after several attempts..

for %%i in (!COBE*_ej!*) do (
  set filename="%%~ni"
  set year=!filename:~11,3!!filename:~18,4!!filename:~16,2!!filename:~14,2!
  ren "%%~i" "%%~i!year!"
  ren "%%~i" "%%~i!year!"
)

endlocal

@echo off & setlocal
for /f "tokens=1-3 delims=_" %%a in ('dir /b COBE*_*_*') do ren "%%a_%%b_%%c" "%%a_%%c"
::--- end
John DOE
  • 400
  • 1
  • 3
  • 18