Help Need a UTIL for Case Sensitive Files.

Help Need a UTIL for Case Sensitive Files.

Post by Erotic Deliriu » Wed, 20 Nov 1996 04:00:00



does anyone have a utility that will go through and change filenames &
directories from uppercase to lower case.  I need to change everything in a
certian directory including subdirs to lowercase and its about 9000 files.
(no joke)
--
Kelly

 
 
 

Help Need a UTIL for Case Sensitive Files.

Post by Per Kistle » Wed, 20 Nov 1996 04:00:00


Hi

#!/usr/bin/ksh

# Change files and dirnames even in sudirs:
# usage: thisprog u|l

find . -depth -print | {

   while read file; do

      if [[ ${file##*/} = ${0##*/} ]];then
         continue
      fi

      if [[ -d $file || -f $file ]];then

         filealt=$file
         case $1 in

         u|U|g|G) fileneu="${file%/*}/$(print ${file##*/}|tr '[a-z]'
'[A-Z]' )"
                  mv $filealt $fileneu;;

         l|L|k|K) fileneu="${file%/*}/$(print ${file##*/}|tr '[A-Z]'
'[a-z]')"
                  mv $filealt $fileneu;;

         *)       print "\nusage: ${0##*/} u|l\n"
                  exit 1

         esac
      fi
   done

Quote:}

If I missunderstood your question, please mail me:-))

Bye, Per.
--
Per Kistler, Zuerich, Switzerland. (I love unix/ksh/awk/perl/C++)

http://www.micro.biol.ethz.ch/~pkistler
----------------------------------------------------------------------

 
 
 

Help Need a UTIL for Case Sensitive Files.

Post by Francisco Rodrig » Wed, 20 Nov 1996 04:00:00


Hello.


Quote:> does anyone have a utility that will go through and change filenames &
> directories from uppercase to lower case.  I need to change everything in a
> certian directory including subdirs to lowercase and its about 9000 files.

That problem seems too familiar for me...

Quote:> (no joke)

Indeed.

Quote:> --
> Kelly

Just do this:

cd /your/directory
for a in *; do mv $a `echo $a | tr '[:upper:]' '[:lower:]'`; done

This works fine for files. I have never had the need for a recursive
traversal of a directory tree. Comments are welcome.

Hope you find it useful.

---
Greetings from Francisco Rodrigo - System administrator, Virtual Net

 
 
 

Help Need a UTIL for Case Sensitive Files.

Post by Michael Smit » Wed, 20 Nov 1996 04:00:00



> Hello.


> > does anyone have a utility that will go through and change filenames &
> > directories from uppercase to lower case.  I need to change everything in a
> > certian directory including subdirs to lowercase and its about 9000 files.

> That problem seems too familiar for me...

> > (no joke)

> Indeed.

Here's a bit of perl code to convert everything in a directory to
lowercase.  I think it could easily be modified to be recursive, or else
could be combined with find ...

#!/usr/local/bin/perl
$dir = $ARGV[0];
$dir = "." unless $dir;
opendir(DIRHANDLE,$dir);
foreach $in (grep(!/^\.\.?$/,readdir(DIRHANDLE)))
        {
        $out="\L$in";
        die unless rename("$dir/$in","$dir/$out");
        }

 
 
 

Help Need a UTIL for Case Sensitive Files.

Post by Keith Ri » Wed, 20 Nov 1996 04:00:00



>does anyone have a utility that will go through and change filenames &
>directories from uppercase to lower case.  I need to change everything in a
>certian directory including subdirs to lowercase and its about 9000 files.
>(no joke)
>--
>Kelly

Make a shell script called upp2low containing:

  #!/bin/sh
  dirname=`dirname $1`
  basename=`basename $1`
  basenew=`echo $basename | tr A-Z a-z`
  if test "$basenew" != "$basename"; then
    (cd $dirname ; mv $basename $basenew)
  fi

Then invoke it as follows:

  find dir -depth -exec upp2low {} \;

The -depth will make sure that all sub-directories get renamed before
the upper level directories.  The dirname/basename stuff is changing
only the lowest level name; without that it won't work right.

For a System V Unix (rather than BSD), change "tr A-Z a-z" to:

  tr '[A-Z]' '[a-z]'

Keith

 
 
 

Help Need a UTIL for Case Sensitive Files.

Post by Brian Some » Wed, 20 Nov 1996 04:00:00




: does anyone have a utility that will go through and change filenames &
: directories from uppercase to lower case.  I need to change everything in a
: certian directory including subdirs to lowercase and its about 9000 files.
: (no joke)

find certain_directory -depth | while read file; do name=$(echo $file | tr '[A-Z]' '[a-z]'); test $name != $file && mv $file $name; done

--

      <http://www.awfulhak.demon.co.uk/>
Don't _EVER_ lose your sense of humour....
.

 
 
 

Help Need a UTIL for Case Sensitive Files.

Post by Steven G. Karg » Wed, 20 Nov 1996 04:00:00




> [Mucho snippage]

> >Just do this:

> >cd /your/directory
> >for a in *; do mv $a `echo $a | tr '[:upper:]' '[:lower:]'`; done
>                                       ^^^^^^^^^^^^^^^^^^^

> Huh? What version of tr uses that syntax to convert from uppercase to
> lowercase?

man tr

[snip]

      [:class:]  Represents all characters belonging to the defined
character
                class.  Class names are:

                alnum     <alphanumeric characters>
                alpha     <alphabetic characters>
                cntrl     <control characters>
                digit     <numeric characters>
                graph     <graphic characters>
                lower     <lower-case alphabetic characters>
                print     <printable characters>
                punct     <punctuation characters>
                space     <space characters>
                upper     <upper-case characters>
                xdigit    <hexadecimal characters>

--
Steve


http://troutmask.apl.washington.edu/~kargl/sgk.html

 
 
 

Help Need a UTIL for Case Sensitive Files.

Post by Cal Duniga » Wed, 20 Nov 1996 04:00:00



Quote:> does anyone have a utility that will go through and change filenames &
> directories from uppercase to lower case.  I need to change everything in a
> certian directory including subdirs to lowercase and its about 9000 files.

You can use either sed or tr in a set of nested for loops. The
magic is setting up the for loops to avoid overlong argument lists.
Try setting the outer loop to do only the files in the parent
directory and create inner loops for all the subdirectories. You may
need to break down the list of filenames into smaller groups based on
the first character of the filename.

If this is too general, send me an email and I will give you a
skeleton.

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    Cal Dunigan                       My opinions *ARE* the company's

    Consulting, Modeling, Training
//////////////////////////////////////////////////////////////////////

 
 
 

Help Need a UTIL for Case Sensitive Files.

Post by Gora Mohan » Thu, 21 Nov 1996 04:00:00



[Mucho snippage]

Quote:>Just do this:
>cd /your/directory
>for a in *; do mv $a `echo $a | tr '[:upper:]' '[:lower:]'`; done

                                      ^^^^^^^^^^^^^^^^^^^

Huh? What version of tr uses that syntax to convert from uppercase to
lowercase?

Regards,
Gora

 
 
 

Help Need a UTIL for Case Sensitive Files.

Post by H.S. Prasad 4-839 » Thu, 21 Nov 1996 04:00:00


Perl script to do this:

#!/usr/local/bin/perl
# This program will recursively go thro' subdirectories
# and convert the file names to lower case

$dir="/export/home/hprasad/PERL";
&renamefiles($dir, $dir);

sub renamefiles() {

local $fls;

opendir(DIR, $dirnm) or die("Unable to open $dirnm because $!");

closedir(DIR);
chdir($dirnm);

      next if((substr( $fls, 0, 1)) eq "\.");
     (-d $fls)? &renamefiles($fls, $dirnm) : rename($fls, (lc("$fls")));

Quote:}

chdir($oldir);

Quote:}

__END__

-Prasad


>does anyone have a utility that will go through and change filenames &
>directories from uppercase to lower case.  I need to change everything in a
>certian directory including subdirs to lowercase and its about 9000 files.
>(no joke)
>--
>Kelly

 
 
 

Help Need a UTIL for Case Sensitive Files.

Post by Andrew Gier » Thu, 21 Nov 1996 04:00:00



 >> cd /your/directory
 >> for a in *; do mv $a `echo $a | tr '[:upper:]' '[:lower:]'`; done

 Gora> Huh? What version of tr uses that syntax to convert from uppercase to
 Gora> lowercase?

Any version with proper international support. The correct translation from
uppercase to lowercase is locale-dependent; just using '[A-Z]' '[a-z]' isn't
good enough for most languages.

--

"Ceterum censeo Microsoftam delendam esse" - Alain Knaff in nanam

 
 
 

Help Need a UTIL for Case Sensitive Files.

Post by Alan Coopersmi » Thu, 21 Nov 1996 04:00:00



|>   tr "[:lower:]" "[:upper:]" < file-in > file-out
|Huh? What version of tr uses that syntax to convert from uppercase to
|lowercase?

I believe any product marked as "UNIX 95 compliant" or "X/Open
compliant" is required to have a tr that uses that syntax.  In
any case, Solaris 2.x tr, GNU tr, AIX 3.2.x tr, HP/UX 9.0x tr,
and Digital UNIX (aka DEC OSF/1) 3.x tr all support that syntax,
as I'm sure do many other OS'es.

--
________________________________________________________________________


 
 
 

Help Need a UTIL for Case Sensitive Files.

Post by Eric R. Augusti » Thu, 21 Nov 1996 04:00:00




> does anyone have a utility that will go through and change filenames &
> directories from uppercase to lower case.  I need to change everything in a
> certian directory including subdirs to lowercase and its about 9000 files.
> (no joke)
> --
> Kelly

I have a chunk of C code which whill change a string from upper case to
lower case which I use here at work to do a similar task (on directories
of roughly the same size btw):

---

/** mklower.c - take a string and make all upper case letters lowercase
 **
 ** (C)1996 Eric R. Augustine
 **
 ** compile with "cc -o mklower mklower.c"
 **
 **/
#include <stdio.h>
#include <ctype.h>

int main(argc,argv)
        int argc;
        char **argv;
        {
        if(argc == 1)
                return -1;
        for(;putc(tolower(*argv[1]++),stdout) != '\0';);
        return 0;
        }

---

In combination with the following bourne script you should be able to do what
you need:

---
#!/bin/sh
for FILE in *
        do
                NAME=`./mklower $FILE`
                if [ ! -f $NAME ]
                        then
                                mv $FILE $NAME
                fi
        done
exit 0
---

With 9000 files you might have to modify the script to hit wildcards since
a listing of 9000 file names would probably excede the length of line limit
on your system.

I hope this helps --

 --Eric.

 
 
 

Help Need a UTIL for Case Sensitive Files.

Post by Jerry Aguirr » Thu, 21 Nov 1996 04:00:00




> > does anyone have a utility that will go through and change filenames &
> > directories from uppercase to lower case.  I need to change everything in a
> > certian directory including subdirs to lowercase and its about 9000 files.

> You can use either sed or tr in a set of nested for loops. The

Think pipes, not loops!

How about the following script:

#!/bin/sh
find . -name '*[A-Z]*' -print | head -10 | sed -e 's/^/mv /
h
s/^mv//
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
H
g
s/\n//
p' | sh

This will do the renames in a single pass.  No problems with numbers of
files in a directory or total number of files.  Calls "mv" once for each
rename though.  For really big jobs you would want something using a
system
call for rename instead of fork/exec of a process, but good enough for a
once off.

                        Jerry Aguirre
                        Senior Systems Administrator
                        WhoWhere?
                        2570 West El Camino Real
                        Suite 309
                        Mountain View, CA 94040

 
 
 

Help Need a UTIL for Case Sensitive Files.

Post by Frederic MARA » Fri, 22 Nov 1996 04:00:00



>Hello.

>> does anyone have a utility that will go through and change filenames &
>> directories from uppercase to lower case.  I need to change everything in a
>> certian directory including subdirs to lowercase and its about 9000 files.
>Just do this:
>cd /your/directory
>for a in *; do mv $a `echo $a | tr '[:upper:]' '[:lower:]'`; done
>This works fine for files. I have never had the need for a recursive
>traversal of a directory tree. Comments are welcome.

This person should probably add a "-a" to the "tr" command if
necessary, to force use of the ASCII collating sequence : on systems
with  NLS, straight range translation sometimes produces strange
(though perfectly logical) results

-------------------------
   Frederic G. MARAND
  Agorus SA / OSI SARL

-------------------------

 
 
 

1. case-insensitive file system with Apache being case-sensitive.

Hi,
    does anybody know if I can change Apache from being case-sensitive?
The problem is that I've made a web site with a protected area, when I enter
the URL www.mysite.com/protected , I need to enter a password, but if I
enter www.mysite.com/Protected or www.mysite.com/proTected I enter the web
site without bieng prompt to enter a password.

    The only way I figured out is to configure Apache for all the
possibility, like: protected, Protected, PRotected, etc....

Any help will be appreciated.

Thanks.

--
Maxime Paquette

Scripto Centris Inc.
1030 Beaubien Est #103
Montreal, Quebec
H2S 1T4
(514) 277-6148
--

2. named syslog messages

3. Case sensitive file names was Re: SOLARIS RULES, LINUX SUCKS!!!!

4. (Q) Cyclades problems

5. Hacking, Security, Linux, Phreak, Exploits and more...

6. help: case sensitive problem in script

7. Blank Space

8. An editor that is case sensitive

9. konqueror case-sensitive-sort

10. Case-sensitive Domain Names in NN

11. Case Sensitive users in Lotus Domino?

12. SAMBA: case sensitive logon from NT-Client