Your question is missing quite a lot of detail so I can only give you a general answer, but I'm going to assume that you already know that you should put the single-file code in a loop and that in your single-file example you currently hardcode the name of the file.
Your first problem would then be how to get the list of files. The functions you want are dir and possibly fullfile, you should check out the documentation by typing doc dir in the console. Matlab has extensive documentation and you can often find answers in there very quickly indeed.
If you need more specific answers you would need to post the code that you have so far, a description of what you want to happen and what is happening. I recommend the stackoverflow.com/tour as a good introduction to how to pose a good question.