Renaming files

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 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.

 

Thanks in advance

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.