If you're running on a *nix system you may want to look at using find, xargs, and sed. Sorry I can't give you the syntax at the moment but you can google for the three of them and find several good examples. Matt Sent via BlackBerry by AT&T -----Original Message----- From: Steve <admin@xxxxxxxxxxxxxxxxx> Date: Sat, 12 Jun 2010 15:24:39 To: <php-general@xxxxxxxxxxxxx> Subject: Re: How to change the first line of a text file On 6/12/2010 2:10 PM, Richard Kurth wrote: > > I have around 6000 text files and I need to change the first line on > every one of them. > > The first line is the title of the article and I need it look like > this <title>the name of the article</title> > > every file has the first line and the it starts the article on the > second line > > The files are in many directory under one main directory > like this > > top directory > fashion-school > Dogs > DentalAssistant > etc.......... > > I need a script that will loop through each directory look at each > file extract the first line and replace it with the example above. > I have figured out how to pull the first line into an array but I > don't no where to go from there to look in each directory and the > write the data back at the top. > > $f = file('GENERAL HISTORY OF DOGS.txt'); > $a = '<title>' . $f[0] . '</title>'; > echo $a; > > > Something like this should do what you want: http://pastebin.com/jKvAiGYa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php