Re: changing the name of exported file without typing
- To: mathgroup at smc.vnet.net
- Subject: [mg84748] Re: [mg84732] changing the name of exported file without typing
- From: "Louis A. Talman" <talmanl at mscd.edu>
- Date: Sat, 12 Jan 2008 05:17:37 -0500 (EST)
- References: <200801120307.WAA19305@smc.vnet.net>
On Jan 11, 2008, at 8:07 PM, Jack Yu wrote: > I tried to save energy by using the Do loop > > Do[Export[Print["f",r,".dat"],f[r]],{r,0,2}] > > but it does not work, saying that the format cannot be recognised > from the printed string. Does anyone know how to loop over the > file names? Any help would be much appreciated. Drop the Print instruction (and its associated square brackets), change the first two commas to the string concatenation operator <>, and wrap ToString around the first instance of r: Do[Export["f" <> ToString[r] <> ".dat"], f[r]], {r, 0, 2}] Note: If you have very many of these things, you may want to add 100 (or 1000, or even 10000) to that first instance of r. Otherwise you might be in for an unpleasant surprise when your operating system sorts your files into an unexpected order. Thus, I'd do: Do[Export["f" <> ToString[100 + r] <> ".dat"], f[r]], {r, 0, 2}] --Lou Talman Department of Mathematical and Computer Sciences Metropolitan State College of Denver <http://clem.mscd.edu/%7Etalmanl>
- References:
- changing the name of exported file without typing
- From: Jack Yu <Jack.Yu@astro.cf.ac.uk>
- changing the name of exported file without typing