# Batch script to search for particular file pattern and then rename it



## program_learner (Nov 18, 2010)

Input Parameter would be following

Folder Path (c:\test)
Filename Pattern(????.*)
Filename (AMPE.DMNT­_ZX.2010061401)
File extension(.zip)
Existing FileName(AMPE.DMNT­_ZX.2010061401.zip)
NewFileName Pattern(????#*)
File to be renamed as(AMPE#DMNT­_ZX.2010061401.zip)

In this way the script need to rename all .zip files there in the c:\test folder and having a particular pattern like(????.).

Could you plz help me regarding the same

Thanks,
Program Learner


----------



## Squashman (Apr 14, 2005)

Is it always the fifth position you need to change?
Or is it always the first period you need to change?


----------



## program_learner (Nov 18, 2010)

It is the first period I want to change


----------



## Squashman (Apr 14, 2005)

```
@echo off
pushd C:\test
FOR /F "tokens=1* delims=." %%A IN ('dir /b /a-d *.zip') DO rename "%%A.%%B" "%%A#%%B"
popd
```


----------

