transforming survey values

Hi All.

I am looking to create transform the user input values from a user survey.
The idea is to accept filenames as input, and the input will then be passed onto my script in this format.
‘file1’,‘file2’,‘file3’

The challange I have here is that I will create the survey to have lets say fields for 5 files, sometimes the user might only be passing 1 or 2 files and in other cases they may be passing 5 files. Where a file path is not empty, it should be transformed to the format

‘file1’,‘file2’,‘file3’

Thanks in advance.