Re: list of file names
- To: mathgroup at smc.vnet.net
- Subject: [mg44858] Re: list of file names
- From: "Peltio" <peltio at twilight.zone>
- Date: Thu, 4 Dec 2003 03:04:15 -0500 (EST)
- References: <bqkb9o$hlr$1@smc.vnet.net>
- Reply-to: "Peltio" <peltioNOSP at Miname.com.invalid>
- Sender: owner-wri-mathgroup at wolfram.com
"Flurchick, Kenneth M" wrote >I want to create a list of file names >rootXXX.dat >where XXX is an integer fixed width A similar problem was addressed in the Mathematica Journal, volume 4-Issue 1. We have to modify that solution to allow for the fixed width of the numeric part of the filename. It is easily done with PadLeft (and if your version does not support this latter function, it is easy to implement it with a few lines of code) padnum[n_,maxd_] := PadLeft[ IntegerDigits[n], maxd] buildname[prefix_String, filetype_String, n_Integer, maxd_:3] := StringJoin[prefix, ToString /@ padnum[n, maxd], ".", filetype] Here's what you get with the default padding buildname["root", "dat", 7] "root007.dat" You can add the maximum number of digit as the last parameter in the call: buildname["root", "dat", 7, 2] "root07.dat" buildname["root", "dat", 7, 5] "root00007.dat" And here's the table: Table[buildname["root","dat",k],{k,0,999}] -suppressed- hope this help, Peltio -- Invalid address in reply-to. Crafty demunging required to mail me.