MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

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>




  • Prev by Date: Re: changing the name of exported file without typing
  • Next by Date: Re: changing the name of exported file without typing
  • Previous by thread: changing the name of exported file without typing
  • Next by thread: Re: changing the name of exported file without typing