windows - Batch File to insert char in file name for multiple files in a folder -


i have series of files have names this:

chart_loan_6516_20130502.pdf  chart_loan_2158_20130502.pdf  chart_loan_78986_20130502.pdf 

each file starts chart_loan_ next number different , last number date created.

i insert 0_ after chart_loan_number_ each file. listed below:

chart_loan_6516_0_20130502.pdf  chart_loan_2158_0_20130502.pdf  chart_loan_78986_0_20130502.pdf 

through research i've found out insert char not when name changing each file.

@echo off setlocal enabledelayedexpansion set old=chart_loan_ set new=chart_loan_0_ /f "tokens=*" %%f in ('dir /b *.jpg') (   set newname=%%f   set newname=!newname:%old%=%new%!   move "%%f" "!newname!" ) 

the above code change static portion of file want, don't know how modify code compensate changing loan number.

try this:

@echo off &setlocal /f "tokens=1-3*delims=_" %%i in ('dir /b /a-d *.pdf ^| find /i /v "_0_"') ren "%%i_%%j_%%k_%%l" "%%i_%%j_%%k_0_%%l" 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -