Re: converting .php files to .dhtml

From: Alan Cox (alan_at_lxorguk.ukuu.org.uk)
Date: 07/19/05

  • Next message: Bob Goodwin: "Problem adding TTF fonts -"
    To: For users of Fedora Core releases <fedora-list@redhat.com>, Ankush Grover <ankush174@gmail.com>
    Date: Tue, 19 Jul 2005 14:36:20 +0100
    
    

    On Maw, 2005-07-19 at 18:16 +0530, Ankush Grover wrote:
    > I wanted to test this out but out application is big and there are
    > lots of subdirectories and many php files (500 files).So it is
    > difficult to change the extension of every php file manually.

    Its actually one of the harder problems in shell script to do this

    The tools you need are "basename" "find" and "mv"

    Basename will trim the ending off a name

    eg

    %basename fred.php .php
    fred

    mv you hopefully know

    and find generates a list of files matching some rules and optionally
    applies an action to them. So we can do

    find . -name "*.php" -print

    and get a list of the PHP files

    So

    for i in $(find . -name "*.php" -print)
    do
            echo $i
    done

    will also print all the names using shell script

    Next we can do

    for i in $(find . -name "*.php" -print)
    do
            echo $(basename $i .php)
    done

    and we should see all the names without php

    and finally (after making a backup!)

    for i in $(find . -name "*.php" -print)
    do
            mv $i $(basename $i .php)".dhtml"
    done

    You might need more quotes if you use filenames containing spaces or *
    but I've left that out to avoid confusion in the explanation

    -- 
    fedora-list mailing list
    fedora-list@redhat.com
    To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list
    

  • Next message: Bob Goodwin: "Problem adding TTF fonts -"

    Relevant Pages

    • Re: Need advice on SSI exec cmd and php files
      ... Further, if I understand correctly, inclusion of PHP files with exec cmd would run them as shell script ... something else than html files. ... Set expose_php to 0 in your php.ini and the requested PHP files should send the appropriate headers, this includes a process returning a 304 status code if the clients' cache is up to date (checking ...
      (comp.infosystems.www.servers.unix)
    • Re: converting .php files to .dhtml
      ... get more some command sample in basename and lowercase script ... > each directory contains many .php files. ...
      (Fedora)
    • Re: converting .php files to .dhtml
      ... On Tuesday 19 July 2005 15:18, Ankush Grover wrote: ... > I want to convert all the .php files under the main directory and ... > under its subdirectories to .dhtml. ... To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list ...
      (Fedora)