1

I am trying to fix some code for a client. The issue is, we have .CSV files that are being written in ColdFusion but duplicates are constantly being generated for some reason, even with nameConflict = "Overwrite" in there. I am seeing that nameConflict may not even work with cffile action="write", how could I add maybe just an ascending number to the end of a duplicate file name every time it is generated? The CSV files simply show customer renewal information.

<cfif arguments.isRenewal EQ "Y">
    <cffile action="write" file="#filename#" nameconflict="overwrite"               output='"Capital","#custName#","","#getCustomer.fname#","#getCustomer.lname#","#getCustomer.serviceAddress1#","#getCustomer.serviceAddress2#","#getCustomer.serviceCity#","#getCustomer.serviceState#","#getCustomer.serviceZip#","#cleanPhone#","#cleanMobilePhone#","#getCustomer.email#","#getCustomer.billingAddress1#","#getCustomer.billingAddress2#","#getCustomer.billingCity#","#getCustomer.billingState#","#getCustomer.billingZip#","0","N/A","Electric","#getCustomer.sdi#","#getCustomer.sdi#","#getProvider.utilityCode#","#getOffer.rateSchedule#","#getOffer.productCode#","#getOffer.rate/100#","kWh","$","#getOffer.rackRateName#","#DateFormat(now(), "yyyy-mm-dd")#","#startDate#","#getOffer.term#","Internet","","","","","","","","","","","","","M2M","#getOffer.evergreenProduct#","Y"'>
<cfelse>
    <cffile action="write" file="#filename#" nameconflict="overwrite" output='"Capital","#custName#","","#getCustomer.fname#","#getCustomer.lname#","#getCustomer.serviceAddress1#","#getCustomer.serviceAddress2#","#getCustomer.serviceCity#","#getCustomer.serviceState#","#getCustomer.serviceZip#","#cleanPhone#","#cleanMobilePhone#","#getCustomer.email#","#getCustomer.billingAddress1#","#getCustomer.billingAddress2#","#getCustomer.billingCity#","#getCustomer.billingState#","#getCustomer.billingZip#","0","N/A","Electric","#getCustomer.sdi#","#getCustomer.sdi#","#getProvider.utilityCode#","#getOffer.rateSchedule#","#getOffer.productCode#","#getOffer.rate/100#","kWh","$","#getOffer.rackRateName#","#DateFormat(now(), "yyyy-mm-dd")#","#startDate#","#getOffer.term#","Internet","","","","","","","","","","","","","M2M","#getOffer.evergreenProduct#","N"'> 

duplicates snapshot

  • You would have to 1) test for existence of a file 2) parse out any existing number 3) calculate the new number 4) write the file with the number. 5) Create a link to the new file. You may also want to consider just using a file name with a GUID – James A Mohler Dec 15 '16 at 16:03
  • By duplicates, do you mean files in the same directory with exactly the same name? I'm not even sure that there is an operating system that would allow that. – Dan Bracuk Dec 15 '16 at 16:19
  • I wonder if this some browser cacheing issue. Maybe the download appears to not match the file on the server, but in reality the browser is using a cached copy – James A Mohler Dec 15 '16 at 17:41
  • i posted a snap shot of literally, yes duplicate file names in the folder, but the original filenames are from previous years for the same customer – Tyler Austin Dec 15 '16 at 20:09
  • 1
    A screen shot of what exactly? It looks more a browser's listing of downloaded files, which is totally different than an o/s directory listing. Can you clarify. Side note, `nameconflict` only applies to action=upload. – Leigh Dec 16 '16 at 05:18

0 Answers0