Directory listing with file info

This is a discussion on Directory listing with file info within the PHP Language forums, part of the PHP Programming Forums category; [ (-: Tenzel Kim Jensen? ] Tenzel Kim wrote: > Kim Jensen wrote: >> I'd rather have links that read: >&...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 11-16-2004
Pedro Graca
 
Posts: n/a
Default Re: Directory listing with file info

[ (-: Tenzel Kim Jensen? ]

Tenzel Kim wrote:
> Kim Jensen wrote:
>> I'd rather have links that read:
>>
>> Angelina Jolie
>>
>> than
>>
>> angelinajolie

>
> If I was just now creating the whole thing I
> could easily use the first examples as file names, but unfortunately I
> already have thousands of links using the second type of file names so
> going back and changing all of them manually or even by global
> search/replace would take ages.


Write a script to do that for you!

<?php
$oldfiles_dir = 'old/';
$newfiles_dir = 'new/';

foreach ($list as $val) {
/* get $charname :: fopen(), fgets(), fclose() */
copy($oldfiles_dir . $val, $newfiles_dir . $charname);
}

?>

And presto! :-)
--
Mail sent to my "From:" address is publicly readable at http://www.dodgeit.com/
== ** ## !! !! ## ** ==
TEXT-ONLY mail to the complete "Reply-To:" address ("My Name" <my@address>) may
bypass the spam filter. I will answer all pertinent mails from a valid address.
Reply With Quote
  #12 (permalink)  
Old 11-16-2004
Pedro Graca
 
Posts: n/a
Default Re: Directory listing with file info

Erich Musick wrote:
> Pedro Graca wrote:
>> Erich Musick top-posted (and I changed the format):
>>>What about extensions such as pl, py, h, among others?

>>
>> In this case, it didn't seem necessary to make a generic function -- but
>> I agree that would have been a better option from the start :)

>


What about
filename.with.a.lot.of.dots
and
filename_without_dots
?

:-)


The generic function would have to deal with them!

--
Mail sent to my "From:" address is publicly readable at http://www.dodgeit.com/
== ** ## !! !! ## ** ==
TEXT-ONLY mail to the complete "Reply-To:" address ("My Name" <my@address>) may
bypass the spam filter. I will answer all pertinent mails from a valid address.
Reply With Quote
  #13 (permalink)  
Old 11-16-2004
Pedro Graca
 
Posts: n/a
Default Re: Directory listing with file info

Kim Jensen wrote:
> Pedro Graca wrote:
>> Are you really sure you want to do that?
>> You have top open each and every file, read/print its contents, and close
>> the file. It might be a lot slow!

>
> About the slowness. Couldn't it be done so that it only took the files
> starting with a specific letter?
>
> So that if I want to see a listing of the files starting with A I'd open
> dir.php?letter=a


Or you could make a 'index' file and only open that one. Its contents
would be something like:

angelinajolie.txt Angelina Jolie
gwynnethpaltrow.txt Gwynneth Paltrow
judelaw.txt Jude Law
lawrenceolivier.txt Sir Lawrence Olivier
michaelgambon.txt Michael Gambon


Or use a database.


Of course these options assume the 'index' file and the database would
be updated for every new file ... (and deletions and changes).

--
Mail sent to my "From:" address is publicly readable at http://www.dodgeit.com/
== ** ## !! !! ## ** ==
TEXT-ONLY mail to the complete "Reply-To:" address ("My Name" <my@address>) may
bypass the spam filter. I will answer all pertinent mails from a valid address.
Reply With Quote
  #14 (permalink)  
Old 11-16-2004
Erich Musick
 
Posts: n/a
Default Re: Directory listing with file info

The code i posted earlier should work with that...

Pedro Graca wrote:
> Erich Musick wrote:
>
>>Pedro Graca wrote:
>>
>>>Erich Musick top-posted (and I changed the format):
>>>
>>>>What about extensions such as pl, py, h, among others?
>>>
>>>In this case, it didn't seem necessary to make a generic function -- but
>>>I agree that would have been a better option from the start :)

>>

>
> What about
> filename.with.a.lot.of.dots
> and
> filename_without_dots
> ?
>
> :-)
>
>
> The generic function would have to deal with them!
>


--
In Christ,

Erich Musick
http://erichmusick.com

In the same way, let your light shine before others, so that they may
see your good works and give glory to your Father who is in heaven. --
Matthew 5:16 NKJV
Reply With Quote
  #15 (permalink)  
Old 11-17-2004
Kim Jensen
 
Posts: n/a
Default Re: Directory listing with file info

Pedro Graca wrote:
> [ (-: Tenzel Kim Jensen? ]


Heh. That's the problem with having a split personality. Sometimes you
forget which is which :)

Kim Jensen or was that Tenzel Kim???

Reply With Quote
  #16 (permalink)  
Old 11-17-2004
Kim Jensen
 
Posts: n/a
Default Re: Directory listing with file info

Pedro Graca wrote:
> Or use a database.


I was trying to avoid using a database for now, as I know that if I went
ahead with that, it would end up being so huge in scope that I'd never
finish it :)

> Of course these options assume the 'index' file and the database would
> be updated for every new file ... (and deletions and changes).


I have been considering the index file approach. However, considering
the speed problem is mainly a problem I don't want my visitors to
encounter making the slow "grab the info from all the files" version
could be done on my harddrive and the output of the script I could just
copy and paste into an index page. That way the slow stuff will be done
behind the scenes.

Maybe that's the best option. Hadn't considered that until just now.

Kim Jensen

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:05 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0