Page 1 of 1

Re: batch scripting

Posted: 17 Oct 2010 21:12
by kartikramkris
Hello,

I have a 1000 plus files I need to rename them daily

TST.SON.20101013153011.00059
TST.SON.20101013153019.00004
TST.SON.20101013153019.00005
TST.SON.20101013153019.00009
TST.SON.20101013153019.00010
......

I need those to be renamed by

XY153000.004
XY153000.005
XY153000.009
XY153000.010
XY153000.059

I need only dos commands, Since I am new to windows scripting.
need help.
Thanks

Re: batch scripting

Posted: 18 Oct 2010 02:19
by amel27

Code: Select all

@echo off
SETLOCAL EnableDelayedExpansion

for %%a in ("TST.*") do (
  set "$n=%%~na"& set "$x=%%~xa"
  ren "%%a" "XY!$n:~-6,4!00.!$x:~-3!"
)

Re: batch scripting

Posted: 18 Oct 2010 07:05
by kartikramkris
Thanks Amel..

That worked.