renaming contents of directory ...

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
TomSalvato
Posts: 2
Joined: 22 Feb 2014 18:37

renaming contents of directory ...

#1 Post by TomSalvato » 22 Feb 2014 18:43

Hi experts - I hate to admit that my DOS skills have all but abandoned me over the years. What I'm trying to do doesn't sound that difficult, but the 'rename' command is failing me.

I have a directory of a couple hundred .jpg files. Their naming convention is something like this:

dppp2.jpg
djdjj3.jpg
dljdkf8.jpg
dlkdklfj9.jpg

No real size pattern, but they all begin with a 'd' and end with a number, and are all .jpg.

I need to add an 's' to the end of every file. So my examples would look like this:

dppp2s.jpg
djdjj3s.jpg
dljdkf8s.jpg
dlkdklfj9s.jpg

I've tried the following command:

rename d*.jpg d*s.jpg

That clearly is not right. Can anyone help out here?

Thanx in advance.

-TS

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: renaming contents of directory ...

#2 Post by foxidrive » 22 Feb 2014 21:14

Use this command line and then examine renfiles.bat and run it if you are happy with it.

Code: Select all

for %a in (*.jpg) do @echo ren "%a" "%~nas%~xa" >>renfiles.bat

TomSalvato
Posts: 2
Joined: 22 Feb 2014 18:37

Re: renaming contents of directory ...

#3 Post by TomSalvato » 23 Feb 2014 09:05

foxidrive wrote:Use this command line and then examine renfiles.bat and run it if you are happy with it.

Code: Select all

for %a in (*.jpg) do @echo ren "%a" "%~nas%~xa" >>renfiles.bat


This was exactly what I was looking for. Worked perfectly.

Thanx, foxidrive!

-TS

Post Reply