Windows batch script to change names with some logic -


i have directory following layout:

1 януари 2012 2 февруари 2012 1 януари 2013 

and want yyyy-mm-dd:

2012-01-01 2012-02-01 2013-01-01 

Януари / февруари cyrillic names of months map numbers - 01 / 02.

the script has to:

  1. take dir name
  2. rename in correct format

i new batch script coding.

so if me great.

assuming, need rename folders януари , февруари, replace c:\folders real full path target directory, save script test.bat, open cmd prompt script folder, , test it. works me in win10 english dir names regardless of current cmd codepage.

@echo off setlocal enabledelayedexpansion set "dir=c:\folders" /f "tokens=4" %%a in ('chcp') (     if not %%a==855 set "enc=%%a" & chcp 855 >nul) /f "tokens=1,2,3" %%g in ('dir /b /a:d "%dir%"') (     set "yea=%%i" & set "fold=%%g %%h %%i"     /f "tokens=1,2 delims=я" %%b in ("%%h") (         if not %%c.==. (set  mon=01) else set mon=02)     if %%g leq 9 (set dat=0%%g) else set dat=%%g     set "nfold=!yea!-!mon!-!dat!"     move /y "%dir%\!fold!" "%dir%\!nfold!" ) if defined enc chcp !enc! >nul exit /b 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -