Hi
finddata
Please narrow down your question by showing what exactly is giving you trouble. Looks like you are making it more complicated to rename a file.
Maybe you are trying to generate a file based on the input from some existing data. Eg.
If data is having configuration related data, then generate the output file with suffix as .config file
If data is having html related data, then generate the output file with suffix as .html
If that is the case, you can do it in more easier way than doing this renaming stuff like adding the sufix based on the input data.