Thanks for the that solution, John. I should have been more clear that the particular filename I used was just an example and that other files would have other characters besides spaces and ' that would have to be dealt with, too.
So, the easiest route would be to limit acceptable characters to alphanumeric characters. The reason for this is, primarily, that some of the Javascript I use on the photos is picky about naming convention. Rick > -----Original Message----- > From: John M Bliss [mailto:[email protected]] > Sent: Saturday, March 14, 2009 7:50 AM > To: cf-talk > Subject: Re: How can I make this "Replace()" work? > > > <cfset renamedOriginal = Replace(Replace(cffile.serverFile, " ", "", > "all"), > "'", "", "all")> > <cffile action="rename" destination="#ExpandPath(renamedOriginal)#" > source="#ExpandPath(cffile.serverFile)#"> > > On Fri, Mar 13, 2009 at 7:26 PM, Rick Faircloth > <[email protected]>wrote: > > > > > I have an uploaded file named: CIY '06 001.jpg (That's > > CIY<space>'06<space>001.jpg) > > > > I want to change the name of that file to: CIY06001.jpg > > > > By running a replace or regex.replace() or something to remove all > > non-alphanumeric characters, > > > > except the . before the extension. > > > > > > > > I've tried a lot of different ways to rename the file, including: > > > > > > > > <cfset renamedOriginal = #replace(cffile.serverFile, "[^a-zA-Z0-9.]", > "", > > "all")#> > > > > <cfset renamedOriginal = #replace(cffile.serverFile, "[^a-zA-Z0- > 9\.]", "", > > "all")#> > > > > > > > > <cfset renamedOriginal = #regex.replace(cffile.serverFile, "[^a-zA- > Z0-9.]", > > "")#> > > > > <cfset renamedOriginal = regex.replace(cffile.serverFile, "[^a-zA-Z0- > 9.]", > > "")> > > > > > > > > etc., etc., ad nauseam. > > > > > > > > Either the filename is not changed or an error is throw because regex > isn't > > understood. > > > > > > > > Is there a <cfscript> way of doing this with regex.or another > solution? > > > > > > > > How can I make this work? > > > > > > > > Thanks for any feedback! > > > > > > > > Rick > > > > > > > > > > --------------------------------------------------------------------- > ------- > > ------------------------------------------------------ > > > > "It is my experience that most bad government is the result of too > much > > government." - Thomas Jefferson > > > > > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:320527 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

