@Soundavid Declare the list variable as a const at the top of your namespace instead of the var, and use list.clear() before the loop that adds items to the list. Put your replace command in the list.push line.
Also declare the files variable as a reg at the top of your namespace instead of the var. Then you'll have access to the files outside of this function.
Another option entirely is to have two string arrays, one that contains the full paths and one that contains just the file names (for display). Then you can use the index of the name array to get the correct file path.
Lots of choices here!