# File Extension Change Help!



## harlequintp (Jul 24, 2008)

Hi, 

This is my first post so hopefully I will put in everything that is needed. I am using Windows XP and I have a large number of files in a Directory "C:\Sample" all the files are the result of xml shreading in perl, at the moment the file name is something like "280977.XML.result" what I want to do using dos is change them all to txt files so it would read something like "280977.txt" 
I tried using the command (REN "C:\Sample\*.XML.result" *.txt) but my file just becomes "280977.XML.txt" can someone point me in the direction of where I am going wrong.

Thanks
harq


----------



## devil_himself (Apr 7, 2007)

use this batch file

```
@echo off
setlocal
set src=C:\temp
pushd "%src%"
for /f "tokens=1-3 delims=." %%a in ('dir /b /a-d *.XML.*') do echo ren "%%a.%%b.%%c" "%%a.txt"
```


----------



## TheOutcaste (Aug 8, 2007)

Welcome to TSG!

You can also use two *REN* statements from a command prompt, first one removes the *.result* extension which makes *XML* the extension, 2nd one changes *.**XML* to *.txt*:

REN "C:\Sample\*.XML.result" **.*
REN "C:\Sample\*.XML" *.txt

HTH

Jerry


----------

