There is a few ways to make a unique filename.
1. Use a UUID Node Tag "{UUID}" in the Path. Example: c:\temp\{UUID}.txt
2. Increment a number to a base file name for every message processed. To make sure this is always right "First in First Out" is needed to be set in Channel Properties:
a. Create a mapping to lookup the last number used and increment it by one then store it in the Message Cache. Here is the code used in the mapping function.
var fileNameInstance = channelCache.getValue('fileNameInstance') *1;
if (fileNameInstance === 0) {
fileNameInstance++;
}
messageCache.setValue('fileNumber', fileNameInstance);
fileNameInstance++;
channelCache.setValue('fileNameInstance', fileNameInstance);
b. Use the Message Cache in a node tag "{mc:fileNumber}" in the destination node. Example: c:\temp\baseName{mc:fileNumber}.txt