Skip to content

Instantly share code, notes, and snippets.

@evertontrindade
Created September 7, 2016 11:37
Show Gist options
  • Save evertontrindade/fe2446da826d8aca82b52745338dd739 to your computer and use it in GitHub Desktop.
Save evertontrindade/fe2446da826d8aca82b52745338dd739 to your computer and use it in GitHub Desktop.
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
DIRETORIO_BUSCA=/home/everton/Música/pe_zezinho
DIRETORIO_DESTINO=/home/everton/Música/convertido
CONTADOR=0;
CONTADOR_ARQ=0;
cd $DIRETORIO_BUSCA;
for f in *
do
#echo "$f"
DESTINO=$(echo "$f" | sed 's,(,,g' | sed 's,),,g' | sed 's,\,,,g' | sed 'y,áÁàÀãÃâÂéÉêÊíÍóÓõÕôÔúÚçÇ,aAaAaAaAeEeEiIoOoOoOuUcC,' | tr [:upper:] [:lower:] | sed 's, * , ,g' | sed 's, ,_,g');
echo "Ajustando $DESTINO";
mkdir $DIRETORIO_DESTINO/$DESTINO;
cd $DIRETORIO_BUSCA/"$f";
for y in $( ls | grep -v jpg | grep -v JPG | grep -v JPG | grep -v jpeg | grep -v db | grep -v txt | grep -v doc | grep -v desktop.ini | grep -v bmp | grep -v BMP | grep -v pdf)
do
ARQUIVO=$(echo "$y" | sed 's,(,,g' | sed 's,),,g' | sed 's,\,,,g' | sed 'y,áÁàÀãÃâÂéÉêÊíÍóÓõÕôÔúÚçÇ,aAaAaAaAeEeEiIoOoOoOuUcC,' | tr [:upper:] [:lower:] | sed 's, ,_,g');
cp "$y" $DIRETORIO_DESTINO/$DESTINO/"$ARQUIVO";
CONTADOR_ARQ=$(($CONTADOR_ARQ+1));
done;
echo "Total de arquivos: $CONTADOR_ARQ";
CONTADOR_ARQ=0;
CONTADOR=$(($CONTADOR+1));
done
echo echo "Total de diretorios: $CONTADOR";
IFS=$SAVEIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment