Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: reading all the files in one directory

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68916] Re: [mg68884] reading all the files in one directory
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Wed, 23 Aug 2006 07:15:39 -0400 (EDT)
  • References: <200608220920.FAA26936@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On Aug 22, 2006, at 5:20 AM, Ana Sofia Figueiredo wrote:

> Hi,
>
> Could anyone please tell me how can a read all the files in one  
> directory?
> I have to read around 60 files with odd names.

Use SetDirectory to change the working directory if necessary.  Then:

Block[{strm=OpenRead[#],result},result={#,Read[strm]};Close 
[strm];result]&/@FileNames[]

will return a list whose elements are the name of the file and its  
contents, assuming the files contain Mathematica expressions, you can  
play with the form of Read to get the results you need.

Regards,

Ssezi


  • Prev by Date: Re: reading all the files in one directory
  • Next by Date: Random numbers according to a rule / function
  • Previous by thread: Re: reading all the files in one directory
  • Next by thread: Re: reading all the files in one directory