Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,
I have some txt files ending .1, .2, .3, .4 etc. I like to rename all those files into .doc (eg change xxx.1 to xxx.1.doc). Possible???

Go to command shell and move to directory where you have those files, and type:
rename *.txt *.doc
That should do it.

I think it would be ren *.? *.?.doc since they don't appear to have a .txt extension. Also, that should give them the double extension, for example XXX.1.doc.
In that the * means 'any file' and the ? is a wildcard that replaces a single character. That is, it apples to files with an extension 1, 2, 3, a, b, etc. It won't cover two or three character extensions. So if your file is named ???.12 it won't work. In that case you could use ren *.?? *.??.doc
It's going to be easier to rename the files if the directory only contains the files you want renamed and not any others.

In any case, this is not a DOS filename:
xxx.1.doc
=====================================
If at first you don't succeed, you're about average.M2

Hello DAVEINCAPS & all,
Thank you all for your help.
I had a substantial of files with dates appending behind (eg xxxx.26.5.2009.1.104) and I tried ren*.?? *.??.doc. It didnt work as it worked only for 2 char ext. So I changed it to ren*.??? *.???.doc
IT WORKS!

it is very simple.....
copy all the files in a folder.......
create a new file "rename.bat"
right click on it and press edit....
type the following data in it
====@echo off
ren *.* *.doc====
then save the file and run it in the same folder....
and then delete the file "rename.doc"
b'coz it has also been renamed from "rename.bat" to "rename.doc"........

That won't create the double extension the OP wanted:
XXX.1 to XXX.1.doc
And why would you need a batch file to do it anyway?

its so simple "DAVEINCAPS"
if you want double extension, just edit your bat file with following.....===
@echo off
ren *.* *.*.doc===
got it.....??? "DAVEINCAPS"...............
=============
hAnSuM KrIsHnA
-a bLACK hAT hACKER
'N'
-a pRO cRACKER
...........................

So, you mean kind of like what I pointed out in my #2 above? I used ? instead of * in order to isolate the files he wanted changed. It's so simple!
But again, why do you need a batch file? Writing a batch file to run a single command is silly. Just run the command from a prompt and be done with it.
Get it??

K.......I accept my mistake........i m a kid 'n' i m new in dos.....k..??.....
=============
hAnSuM KrIsHnA
-a bLACK hAT hACKER
'N'
-a pRO cRACKER
...........................

Well, for a kid you're doing pretty good. You'll learn a lot in these forums even if you don't contribute.

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |