Generating the title's for alot of HTML pages

  • Tabble
  • Born
  • Born
  • No Avatar
  • Joined: Apr 21, 2004
  • Posts: 4
  • Status: Offline

Post May 24th, 2004, 12:32 pm

I'm working with alot of files, and basically just need to know how to take the file name and add it to the title.

The files are like this for example: led_zeppelin-kashmir.html

and I would need it to automatically take the file name and add it to the title so the end result would look like this:

MySitesName.com - Led Zeppelin - Kashmir

Anyone know how to do this?

Another example just in case, would be like this...

Filename: rolling_stones-paint_it_black.html

End result for title of this html file: MySitesName.com - Rolling Stones - Paint it Black
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post May 24th, 2004, 12:32 pm

  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post May 24th, 2004, 1:02 pm

Providing your filenames are as shown, this should work for you:

Code: [ Select ]
opendir(THISDIR,"/directory/path/to/files");
while ($file = readdir(THISDIR) ){
    push @filenames, $file;
}
closedir(THISDIR);
chomp @filenames;
foreach $fn (@filenames) {
    if ($fn =~ /.+\.html/) {
        my($rawsong,$extention)=split(/\./,$fn);
        my($author,$title)=split(/\-/,$rawsong);
        $author =~ s/_/ /g;
        $title =~ s/_/ /g;
        print qq~Author: $author\nTitle: $title\nPage: $fn\n\n~;
        # You can do what you want with this information now, this is just to show that you do have it
    }
}
  1. opendir(THISDIR,"/directory/path/to/files");
  2. while ($file = readdir(THISDIR) ){
  3.     push @filenames, $file;
  4. }
  5. closedir(THISDIR);
  6. chomp @filenames;
  7. foreach $fn (@filenames) {
  8.     if ($fn =~ /.+\.html/) {
  9.         my($rawsong,$extention)=split(/\./,$fn);
  10.         my($author,$title)=split(/\-/,$rawsong);
  11.         $author =~ s/_/ /g;
  12.         $title =~ s/_/ /g;
  13.         print qq~Author: $author\nTitle: $title\nPage: $fn\n\n~;
  14.         # You can do what you want with this information now, this is just to show that you do have it
  15.     }
  16. }
http://www.disabo.com

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 77 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.