1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

changinf filename case - migrating from Windows to Linux

Discussion in 'HTML & Website Design' started by Svato, Apr 13, 2005.

  1. #1
    I have a site, which has over a hundred pages. All pages contain links, and these links are case insensitive. For example a file has this link:
    <A HREF="MyFile.HTM">
    Now - the files are named in different formats, some uppercase, some lowecase. I need to move the site to a Linux server and I was wondering if anyone knows a way of changining all the filenames to lowercase.
    I am not talking about renaming all files to lowercase, that is not a problem. The problem is to change value of all HREF attributes to lowercase sitewide. Go through each page and change every single link to lowercase. I couldn't figure out how to automate it. Maybe someone has a PHP script which woudl locate the HREF attributes and fix this?
    Or any other suggestions?
    Thanks.
     
    Svato, Apr 13, 2005 IP
  2. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can use sed and awk (there's a function called tolower) on Linux.
     
    J.D., Apr 13, 2005 IP
  3. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This should get you going (no line breaks - it's all one line!):

    $ awk -- '{match($0,"href=\"([^\"]+)\"",m);h=m[1];if(length(h)==0){print $0;}else{h="href=\""tolower(h)"\"";gsub("href=\"[^\"]+\"",h,$0);print $0;}}' filename.html

    Use the for command to process more than one file.

    J.D.
     
    J.D., Apr 14, 2005 IP
  4. Svato

    Svato Peon

    Messages:
    88
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks J.D. I'll try that. Interesting approach.

    I still can't believe that tools like Dreamweaver can't do that. I would think that migrating from Windows to Linux is relatively common...
     
    Svato, Apr 14, 2005 IP