case conversion - SGI

This is a discussion on case conversion - SGI ; Hi Maybe this is a simple question, but I've been really scratching my head trying to get this done: Apart from manually changing every single one, is there a simple way of converting the case of all files in a ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: case conversion

  1. case conversion

    Hi

    Maybe this is a simple question, but I've been really scratching my
    head trying to get this done:

    Apart from manually changing every single one, is there a simple way
    of converting the case of all files in a director(s)? i.e. when you
    copy folders and files from a PC-written CDROM it is sometimes all in
    capitals, which makes any web pages inoperable (due to the wrong case)
    and it looks horrible! I have tried and tried to get perl (uc) and
    shell scripts to do the job, but for some reason they never work for
    me. I searched on the internet but found only man pages about perl.

    Any help would be great, this trivial problem is managing to drive me
    nuts!

  2. Re: case conversion

    In article ,
    Jonathan wrote:
    >Hi
    >
    >Maybe this is a simple question, but I've been really scratching my
    >head trying to get this done:
    >
    >Apart from manually changing every single one, is there a simple way
    >of converting the case of all files in a director(s)? i.e. when you
    >copy folders and files from a PC-written CDROM it is sometimes all in
    >capitals, which makes any web pages inoperable (due to the wrong case)
    >and it looks horrible! I have tried and tried to get perl (uc) and
    >shell scripts to do the job, but for some reason they never work for
    >me. I searched on the internet but found only man pages about perl.
    >
    >Any help would be great, this trivial problem is managing to drive me
    >nuts!


    A relatively simple perl script can fix things, but only
    if the web pages agree on a single case (lower or upper)
    so the direction-to-change-file-names is known.
    If the web pages use mixed case for file names (or worse,
    are inconsistent in references to a single file) it gets much worse.
    Still doable (using links so one has multiple names for a single file)
    but rather a lot of work, in the case of spelling inconsistency.
    (because one has to parse the html to find the spellings used!
    Doable with some perl packages, but still, YUCK!)


    In other words, you have not fully described your problem or
    what would solve it, so nobody has volunteered a script.
    Nor can I quite tell what would help.

    Call me lazy, but a few years ago a CD with back issues
    of "C/C++ Users Journal" had that problem, and I just said forget it
    and never looked at the problem nor ordered a more recent CD from them
    (can't tell from their ads if they ever fixed this problem).


    Regards,
    David B. Anderson davea at sgi dot com http://reality.sgiweb.org/davea

  3. Re: case conversion

    davea@quasar.engr.sgi.com (David Anderson) wrote:

    >In article ,
    >Jonathan wrote:
    >>Hi
    >>
    >>Maybe this is a simple question, but I've been really scratching my
    >>head trying to get this done:
    >>
    >>Apart from manually changing every single one, is there a simple way
    >>of converting the case of all files in a director(s)? i.e. when you
    >>copy folders and files from a PC-written CDROM it is sometimes all in
    >>capitals, which makes any web pages inoperable (due to the wrong case)
    >>and it looks horrible! I have tried and tried to get perl (uc) and
    >>shell scripts to do the job, but for some reason they never work for
    >>me. I searched on the internet but found only man pages about perl.
    >>
    >>Any help would be great, this trivial problem is managing to drive me
    >>nuts!

    >
    >A relatively simple perl script can fix things, but only
    >if the web pages agree on a single case (lower or upper)
    >so the direction-to-change-file-names is known.
    >If the web pages use mixed case for file names (or worse,
    >are inconsistent in references to a single file) it gets much worse.
    >Still doable (using links so one has multiple names for a single file)
    >but rather a lot of work, in the case of spelling inconsistency.
    >(because one has to parse the html to find the spellings used!
    >Doable with some perl packages, but still, YUCK!)
    >
    >In other words, you have not fully described your problem or
    >what would solve it, so nobody has volunteered a script.
    >Nor can I quite tell what would help.
    >
    >Call me lazy, but a few years ago a CD with back issues
    >of "C/C++ Users Journal" had that problem, and I just said forget it
    >and never looked at the problem nor ordered a more recent CD from them
    >(can't tell from their ads if they ever fixed this problem).
    >


    Some time ago I had the same problem. Some people sent
    me these scripts. I hope I have understood you problem
    correctly.
    I don't remember which was the 'best' one, make backups
    before trying them :-)

    Converting the file names to lowercase

    #!/bin/sh
    for i in *
    do
    mv $i `echo $i | tr '[A-Z]' '[a-z]'`
    done

    #!/bin/sh
    find . -type f -print | while read i
    do
    mv $i `echo $i | tr '[A-Z]' '[a-z]'`
    done

    /Bjorn


  4. Re: case conversion

    In article ,
    Jonathan wrote:
    >Hi


    >Maybe this is a simple question, but I've been really scratching my
    >head trying to get this done:


    >Apart from manually changing every single one, is there a simple way
    >of converting the case of all files in a director(s)? i.e. when you
    >copy folders and files from a PC-written CDROM it is sometimes all in
    >capitals, which makes any web pages inoperable (due to the wrong case)
    >and it looks horrible! I have tried and tried to get perl (uc) and
    >shell scripts to do the job, but for some reason they never work for
    >me. I searched on the internet but found only man pages about perl.


    >Any help would be great, this trivial problem is managing to drive me
    >nuts!


    What did you try to do in your shell scripts? This should be pretty
    easy with the tr command. Something along the lines of:

    cd root_of_directory_structure
    find . -print |
    while read uc_name
    do
    lc_name = `echo $uc_name | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz `
    mv $uc_name $lc_name
    done

    Note: I haven't tested this, there's probably a more elegant way, and my
    shell programming is rusty, so check carefully before using this on any
    files and folders you care about. You may need to insert a test after the
    tr command to bypass the mv if $uc_name and $lc_name match. The above
    syntax should be suitable for sh, bash, or ksh.


    Gary

    --
    Gary Heston gheston@hiwaay.net

    Contrary to popular opinion, _not_ everyone loves Raymond.

  5. Re: case conversion

    David Anderson wrote:
    > In article ,
    > Jonathan wrote:
    >>Hi
    >>
    >>Maybe this is a simple question, but I've been really scratching my
    >>head trying to get this done:
    >>
    >>Apart from manually changing every single one, is there a simple way
    >>of converting the case of all files in a director(s)? i.e. when you
    >>copy folders and files from a PC-written CDROM it is sometimes all in
    >>capitals, which makes any web pages inoperable (due to the wrong case)
    >>and it looks horrible! I have tried and tried to get perl (uc) and
    >>shell scripts to do the job, but for some reason they never work for
    >>me. I searched on the internet but found only man pages about perl.
    >>
    >>Any help would be great, this trivial problem is managing to drive me
    >>nuts!

    >
    > A relatively simple perl script can fix things, but only
    > if the web pages agree on a single case (lower or upper)
    > so the direction-to-change-file-names is known.
    > If the web pages use mixed case for file names (or worse,
    > are inconsistent in references to a single file) it gets much worse.


    In 6.5.22 (I think), a new option was added to mkfs_xfs which allowed
    for case-insensitive directory lookups. From the man page:

    -n Naming options.
    ....
    The version=ci suboption enables case-insensitive filenames and
    version 2 directories. Filenames will be stored in directories as
    they were created, but all file or directory name searches will be
    case-insensitive. This feature is normally used only when doing
    file serving to Windows clients.

    Obviously mkfs is a drastic step, so if they work for you, the tr
    solutions would be much better.

    Ivan
    --
    Ivan Rayner
    ivanr@sgi.com

  6. Re: case conversion

    On 10 Apr 2004, Jonathan wrote:

    > Hi
    >
    > Maybe this is a simple question, but I've been really scratching my
    > head trying to get this done:
    >
    > Apart from manually changing every single one, is there a simple way
    > of converting the case of all files in a director(s)? i.e. when you
    > copy folders and files from a PC-written CDROM it is sometimes all in
    > capitals, which makes any web pages inoperable (due to the wrong case)
    > and it looks horrible! I have tried and tried to get perl (uc) and
    > shell scripts to do the job, but for some reason they never work for
    > me. I searched on the internet but found only man pages about perl.
    >
    > Any help would be great, this trivial problem is managing to drive me
    > nuts!


    man tr

    Jamie Bowden
    --
    "It was half way to Rivendell when the drugs began to take hold"
    Hunter S Tolkien "Fear and Loathing in Barad Dur"
    Iain Bowen


  7. Re: case conversion

    My only goal was to convert a whole directory of upper case filenames,
    which are all different, to lower case file names.


    > Some time ago I had the same problem. Some people sent
    > me these scripts. I hope I have understood you problem
    > correctly.


    Wow thanks! These two scripts did the trick

    before:

    monkey 75% ls
    TEST1.TXT TesT2.Txt convert_case1* test.txt
    TEST3.txt convert_case* jfdskkdd.txt


    after:

    monkey 77% ls
    convert_case* jfdskkdd.txt test1.txt test3.txt
    convert_case1* test.txt test2.txt

    Both scripts seem to acheive the same outcome, but will overwrite
    existing lowercase files with their uppercase versions (i.e. TEST.TXT
    replaced the existing test.txt), as there is no checking done. Not a
    problem for me though, as all the filenames are different and are all
    in upper case.

    Obviously the simple scripts kindly provided could be expanded upon to
    do more (such as entire directory trees, and duplicate filename
    checking etc), but for my purposes they do just fine.

    Thankyou all for your help on this matter!
    (Maybe it's high-time I spent a while learning some basic scripting
    for myself)

+ Reply to Thread