Monday, November 3, 2014

Lowerit

Gosh, I was going through some really old files and found the file names were all in upper case. Normal for things coming from an old DOS machine.



$ ls
ACCT.DAT      ADVERT.BAS  ARPTINV.BAS   BCREATEI.BAS  DBEDIT.BAS    GAMMNDBL.BAS  LIZZYRPT.BAS  LSTMORTI.BAS  RECEDIT.BAS   SEBRWKRL.BAS
ADDRADD.BAS   ANSWER.ASC  AS2RCUST.BAS  BFLISTI.BAS   DBPREP.BAS    GAMORACL.BAS  LIZZYTRM.BAS  LSTREC.BAS    RLETTER       SENSOR.BAS
ADDRFIL.BAS   ANSWER.CIT  AS2RREV.BAS   BINCOMEI.BAS  DUMBMENU.BAS  HPOPMENU.BAS  LIZZYWRD.BAS  LSTSCHDP.BAS  SAMPLE        TEMP.DAT
ADDRPRNT.BAS  ANSWER.MSG  ASCFLCMP.BAS  BMENU.BAS     FIXEDFIL.TXT  LIBFIX.BAS    LSTASC.BAS    MAPDICT.BAS   SEBRCUST.BAS  VPOPMENU.BAS
ADVANWIN.BAS  ARC.TTP     BCLOSEI.BAS   DATAFILE.BAS  GAMELIZA.BAS  LIZZYCLC.BAS  LSTIOLOG.BAS  PHNDTCT.BAS   SEBRREV.BAS   WORDEDIT.BAS

When you are used to dealing with lower case, this can be a challenge. We used to say that people who used upper case were always yelling. (from the old bbs days).

Needed to change the filenames on these files to lower case.  Fortunately found a script to do just that. so the results were:

$ ls
acct.dat      advert.bas  arptinv.bas   bcreatei.bas  dbedit.bas    gammndbl.bas  lizzyrpt.bas  lstmorti.bas  recedit.bas   sebrwkrl.bas
addradd.bas   answer.asc  as2rcust.bas  bflisti.bas   dbprep.bas    gamoracl.bas  lizzytrm.bas  lstrec.bas    rletter       sensor.bas
addrfil.bas   answer.cit  as2rrev.bas   bincomei.bas  dumbmenu.bas  hpopmenu.bas  lizzywrd.bas  lstschdp.bas  sample        temp.dat
addrprnt.bas  answer.msg  ascflcmp.bas  bmenu.bas     fixedfil.txt  libfix.bas    lstasc.bas    mapdict.bas   sebrcust.bas  vpopmenu.bas
advanwin.bas  arc.ttp     bclosei.bas   datafile.bas  gameliza.bas  lizzyclc.bas  lstiolog.bas  phndtct.bas   sebrrev.bas   wordedit.bas

Much better now. Oh yes how to do it.

#!/bin/sh
# lowerit
# convert all file names in the current directory to lower case
# only operates on plain files--does not change the name of directories
# will ask for verification before overwriting an existing file
for x in `ls`
    do
        if [ ! -f $x ]; then
             continue
        fi
        lc=`echo $x  | tr '[A-Z]' '[a-z]'`
        if [ $lc != $x ]; then
             mv -i $x $lc
        fi
    done

Pretty nifty!

No comments:

Post a Comment