Batch routine to change file names

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
NelsonS
Posts: 2
Joined: 22 May 2008 11:39

Batch routine to change file names

#1 Post by NelsonS » 22 May 2008 20:50

I need some help creating a batch file to rename some 6k files.
The file names are seven numbers dot jpg.
NNNNNNN.jpg (b4)
I would like to change the first number only and swap it with 3 letters and a dash.
LLL-NNNNNN.jpg (after)
I would like to do that to all contents of a given directory until every file is modified in that format.

Thanks in advance for the assist.

Nelson

jeb
Expert
Posts: 1042
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

#2 Post by jeb » 25 May 2008 06:16

Hi Nelson,

begin with this

Code: Select all

@echo off
setlocal enableextensions
setlocal enabledelayedexpansion

set srcPath=c:\temp\hund
set prefix=LLL-
echo %prefix%

for %%a in (%srcPath%\*.*) do (
   set oldName=%%~nxa
   set newName=%%~dpa%prefix%!oldName:~1!
   echo ren !oldName! !newName!
)


jeb

NelsonS
Posts: 2
Joined: 22 May 2008 11:39

Batch

#3 Post by NelsonS » 11 Jun 2008 20:48

thanks Jeb,

I'll try that.

Post Reply