# Renaming files

**URL:** https://www.finalbuilder.com/forums/t/renaming-files/4322
**Category:** Discussion
**Created:** [August 18, 2008, 3:12am UTC](https://www.finalbuilder.com/forums/t/renaming-files/4322 "2008-08-18T03:12:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [August 18, 2008, 3:12am UTC](https://www.finalbuilder.com/forums/t/renaming-files/4322/1 "2008-08-18T03:12:57Z")

</div>

Hello

several files are daily generated like MiXBest2208\_18\_08\_12345678.txt. The common of all files ist they name starting with MiXbest. I wold like to rename them all to&nbsp;a mixbest\_1.txt. The first file will get the ending\_1, the secoundthe ending\_2 and so one.

Would realy appreciate if someone could give me a example.

&nbsp;

Thanks in advance

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [August 19, 2008, 3:23am UTC](https://www.finalbuilder.com/forums/t/renaming-files/4322/2 "2008-08-19T03:23:54Z")

</div>

Hi Kurt,   
  
 Try this:   
  
 1. Define two variables: CurrentFileName, CurrentFileCounter   
 2. Add a Define FileSet action, set name to MiXFiles, base directory to whereever the files are located, and change the filter to MiXBest\*.\*   
 3. Add a “File/Fileset Iterator” action. Set fileset to MiXFiles, Iterator variable to CurrentFileName.   
 4. Add a “Rename File or Directory” action as a child action of the FileSet Iterator action. Set rename file to %CurrentFileName%, New Name is: MiXBest\_%CurrentFileCounter%.txt   
 5. In the “OnFirstRun” script event of the iterator action, put the following code: CurrentFileCounter = 1   
 6. In the “OnAfterEachIteration” script event of the iterator action, put the following code: CurrentFileCounter = Action.CurrentIteration + 1   
 7. Run the project!   
  
 hth.
