Differenze tra le versioni di "Loverit.sh"

Da WikiSitech.
Vai alla navigazioneVai alla ricerca
(Nuova pagina: <code> #!/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 verifi...)
 
(lowerit / upperit)
 
(Una versione intermedia di uno stesso utente non è mostrata)
Riga 16: Riga 16:
 
done
 
done
 
</code>
 
</code>
 +
 +
<code>
 +
#!/bin/sh
 +
# upperit
 +
# convert all file names in the current directory to upper 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
 +
</code>
 +
 +
<code>
 +
#!/bin/sh
 +
# upperit
 +
# convert all file names in the directory passed as first argument to upper case
 +
# only operates on plain files--does not change the name of directories
 +
# will ask for verification before overwriting an existing file
 +
if [ "$1" != "" ]; then
 +
  cd $1
 +
fi
 +
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
 +
 +
if [ "$1" != "" ]; then
 +
  cd ..
 +
fi
 +
</code>
 +
Esempio di conversione in maiuscolo di tutta una struttura di cartelle
 +
find . -maxdepth 1 -name "[0-9]*" -type d -exec /usr/local/Sitech/upperit.sh '{}' \;

Versione attuale delle 17:35, 30 gen 2009

  1. !/bin/sh
  2. lowerit
  3. convert all file names in the current directory to lower case
  4. only operates on plain files--does not change the name of directories
  5. 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

  1. !/bin/sh
  2. upperit
  3. convert all file names in the current directory to upper case
  4. only operates on plain files--does not change the name of directories
  5. 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

  1. !/bin/sh
  2. upperit
  3. convert all file names in the directory passed as first argument to upper case
  4. only operates on plain files--does not change the name of directories
  5. will ask for verification before overwriting an existing file

if [ "$1" != "" ]; then

 cd $1

fi 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

if [ "$1" != "" ]; then

 cd ..

fi Esempio di conversione in maiuscolo di tutta una struttura di cartelle

find . -maxdepth 1 -name "[0-9]*" -type d -exec /usr/local/Sitech/upperit.sh '{}' \;