in reply to Combine files with same extension in new file
Some general tips:
Other than that: design an algorithm first, then code it up. Have fun.