Create output files from an input file that has the same name as it for all file in a directory

Good morning.
I would need a script that reads information in one file and reports it in an order I indicated in another text file.
With simple input/output statements I managed to do it but the problem is that I need this to be done for all the files in the directory and that each output produced has the same name as the file from which it comes.
Could someone help me?
I am new to Python but I have to learn quickly for my master’s thesis work.

Welcome to the Anaconda Community!

One thing you could do is use the os.listdir() command to get a list of files and names in a directory, then perhaps use a ‘for-range()’ statement to loop over the filenames.

Here is a reference that should help:

Let me know how the project goes!