CFLib.org – Common Function Library Project

UniqueFilename(prepend, ext)

Last updated September 20, 2004

Version: 2 | Requires: ColdFusion 5 | Library: FileSysLib

 
Rated 0 time(s). Average Rating: 0

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:

view plain print about
<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:

view plain print about
<cfscript>
/**
 * 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#";
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson