[thelist] Upload file with hyphen in name
Joshua Olson
joshua at waetech.com
Mon Feb 13 08:48:40 CST 2006
> -----Original Message-----
> From: Casey
> Sent: Monday, February 13, 2006 9:26 AM
>
> > a. Naming conventions should never be system critical items
> > 2. Escape all special characters
>
> a. Yes, good advice. Maybe I overstated... they have
> thousands of images with hyphens in the name already, and
> telling them they have to rename them all would mean loosing
> the client.
Casey,
Renaming thousands of files isn't really all that hard if you have a program
to perform the actions. I needed to change @20 to spaces on a few thousand
files a while back and I create a workable solution via Cold Fusion. Even
if you don't use Cold Fusion, perhaps you can utilize the concept, if
necessary:
-- file: fixfilenames.cfm
<cfparam name="attributes.directory" default="#ExpandPath('.')#">
<cfdirectory action="LIST" directory="#attributes.directory#"
name="get_files">
<cfoutput query="get_files">
<cfif name NEQ "." AND name NEQ "..">
<cfif name CONTAINS "@20">
Fixing: #name#<br />
<cffile action="RENAME" source="#attributes.directory#\#name#"
destination="#Replace('#attributes.directory#\#name#', '@20', ' ', 'ALL')#">
</cfif>
<cfif type IS "Dir">
<cf_fixfilenames directory="#attributes.directory#\#name#">
</cfif>
</cfif>
</cfoutput>
-- file: test.cfm
<cf_fixfilenames directory="c:\testfolder\">
Essentially what happens is that I would call test.cfm, which would launch
fixfilenames.cfm. Fixfilenames.cfm would then pull up a directory list and
perform a rename on all the files. If it encountered a sub-directory, it
would call itself using the sub-directory as the new starting point.
The code I used specifically solved my problem, but could easily be adapted
to solve most file renaming tasks.
<><><><><><><><><><>
Joshua L. Olson
WAE Tech Inc.
http://www.waetech.com/
Phone: 706.210.0168
Fax: 413.812.4864
Monitor bandwidth usage on IIS6 in real-time:
http://www.waetech.com/services/iisbm/
More information about the thelist
mailing list