shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Script para estudo


From: voyeg3r
Subject: Script para estudo
Date: Sun, 22 Jul 2007 20:05:30 -0000
User-agent: eGroups-EW/0.82

estou enviando um script para estudo, queria uma explicação 
sobre o uso do "shift" e outros detalhes do script, alguém 
poderia fazer o favor de comenta-lo?

O propósito é consertar o charset, só consegui usar 
o zzarrumanome após aplicar este script!


#!/bin/bash
#mviconv 1.1
#copyright 2002 Manuel Amador (Rudd-O).  This software is under the GPL
#http://www.usm.edu.ec/~amadorm/

if [ "$3" == "" ] ; then
 echo "mviconv 1.0 by Rudd-O."
 echo "sorts a folder full of MP3s into artist and album folders"
 echo "This software is under the GPL.  ABSOLUTELY NO WARRANTY."
 echo
 echo "usage: $0 [-r] --from=encoding1 --to=encoding2 <files>"
 exit 1
fi

if [ "$1" == "-r" -o "$1" == "-R" ] ; then
 recursive=$1
 shift
fi

from="$1"
shift
to="$1"
shift

while [ "$1" != "" ]; do

 filename="$1"
 newfilename=`echo $filename | iconv $from $to `

 if [ "$filename" != "$newfilename" ]; then
   echo \($SHLVL\) Processing $PWD/$newfilename
   mv "$filename" "$newfilename" > /dev/null
   [ $? -ne 0 ] && exit 1
 fi

 #debugging purposes
 #newfilename="$filename"
 if [ -d "$newfilename" -a "$recursive" != "" ] ; then
   directorioviejo="$PWD"
   cd "$newfilename"
   if [ "$PWD" !=  "$directorioviejo" ]; then
      $0 $recursive $from $to *
   fi
   cd "$directorioviejo"
 fi


 shift

done




reply via email to

[Prev in Thread] Current Thread [Next in Thread]