CFLib.org – Common Function Library Project

UniqueFilename(prepend, ext)

Last updated September 20, 2004

author

Joshua Miller

Version: 2 | Requires: CF5 | Library: FileSysLib

Description:
Creates a unique filename from a passed prefix, file extension and current date/time. Filename format: prepend_080701_023052.ext

Return Values:
Returns a string.

Example:

<CFOUTPUT>
#uniquefilename('nws','xml')#
</CFOUTPUT>

Parameters:

Name Description Required
prepend Prefix for the filename. Yes
ext Extension to give the file. Yes

Full UDF Source:

/**
 * Creates a unique filename from a passed prefix, file extension and current date/time.
 * Modified by RCamden, changed hh to HH, thanks to Nathan D. for idea.
 * 
 * @param prepend 	 Prefix for the filename. (Required)
 * @param ext 	 Extension to give the file. (Required)
 * @return Returns a string. 
 * @author Joshua Miller (josh@joshuasmiller.com) 
 * @version 2, September 20, 2004 
 */
function uniquefilename(prepend,ext)
{
  Return "#prepend#_#dateformat(now(),"mmddyy")#_#timeformat(now(),"HHmmss")#.#ext#";
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson