Re: batch scripting

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
kartikramkris
Posts: 2
Joined: 17 Oct 2010 21:00

Re: batch scripting

#1 Post by kartikramkris » 17 Oct 2010 21:12

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

amel27
Expert
Posts: 177
Joined: 04 Jun 2010 20:05
Location: Russia

Re: batch scripting

#2 Post by amel27 » 18 Oct 2010 02:19

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

kartikramkris
Posts: 2
Joined: 17 Oct 2010 21:00

Re: batch scripting

#3 Post by kartikramkris » 18 Oct 2010 07:05

Thanks Amel..

That worked.

Post Reply