Ir para o conteúdo

Espírito Livre

Voltar a Blog
Tela cheia

Conhecendo o Nautilus – Oitavo Script – Tirando Espaços e Padronizando Arquivos

23 de Dezembro de 2012, 22:00 , por Desconhecido - 0sem comentários ainda | No one following this article yet.
Visualizado 42 vezes
scripts-msg-plus
Para que você possa instalar os Scripts em seu Nautilus é bem simples, só precisa de 4 passos:
1 – Abra o Gedit ou o seu editor de texto preferido;
2 – Copie e cole o texto do Script, que se encontra no final desta postagem;
3 – Salve o arquivo em “/home/seu-usuario/.gnome2/nautilus-scripts/” e dê um nome bem sugestivo para esse arquivo;
4 – Abra um terminal, logue-se como root e digite:
chown seu-usuario.seu-usuario -R /home/seu-usuario/.gnome2/nautilus-scripts/ && chmod +x /home/seu-usuario/.gnome2/nautilus-scripts/ + enter
Após os 4 passos acima o Script já estará disponível no menu de contexto do Nautilus.
Se quiser ver a primeira postagem e saber mais sobre os Scripts do Nautilus:
Acesse aqui!!!!

Ai vai o Oitavo script da série:
Tirando Espaços e Padronizando Arquivos

Esse Script permite que você pegue uma pasta com um número infinito de arquivos totalmente fora do padrão, com acentos, caracteres especiais e espaços em seu nome e os coloca no formato padrão, pois ao rodar o Script dentro desta pasta todos os arquivos existentes serão transformados em arquivos sem espaço, sem acento, sem caracteres especias e em letras minusculas.

Obs.: É só rodar e esperar, pois não existem parâmetros neste Script.

Dependências:

#!/bin/bash

#virmal_divx 2011

(
echo “# Estamos trabalhando, por favor aguarde o processo terminar !!!”
rename ‘y/A-Z/a-z/’ *
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘s/ /_/g’`”;done

find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-V-X-W-Y-Z/a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-x-w-y-z/’`”;done

find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Á/a/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/É/e/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Í/i/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Ó/o/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Ú/u/’`”;done

find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/á/a/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/é/e/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/í/i/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/ó/o/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/ú/u/’`”;done

find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Ç/c/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Ã/a/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Ĩ/i/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Õ/o/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Ũ/o/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Ü/u/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Â/a/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Ê/e/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Ẽ/e/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Î/i/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Ô/o/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/Û/u/’`”;done

find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/ç/c/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/ã/a/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/ẽ/e/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/ĩ/i/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/õ/o/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/ũ/u/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/ü/u/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/â/a/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/ê/e/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/î/i/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/ô/o/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/û/u/’`”;done

### Trocar os ()[]{}ªº°!?@ sobrando por _
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/(/_/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/)/_/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/[/_/'`";done
find | while read FN;do mv "$FN" "`echo $FN | sed -r -e 'y/]/_/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/ª/_/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/º/_/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/°/_/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/!/_/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/?/_/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/@/_/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/#/_/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/$/_/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/%/_/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/&/_/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/_././’`”;done

### Trocar os – sobrando por _
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/-/_/’`”;done
find | while read FN;do mv “$FN” “`echo $FN | sed -r -e ‘y/_-_/_/’`”;done

### Trocar os pontos sobrando por vazio
for FILE in $(find . -type f -name ‘*……*’); do NEWNAME=$(echo $FILE|sed s/’……’/_/); mv -v $FILE $NEWNAME; done
for FILE in $(find . -type f -name ‘*…..*’); do NEWNAME=$(echo $FILE|sed s/’…..’/_/); mv -v $FILE $NEWNAME; done
for FILE in $(find . -type f -name ‘*….*’); do NEWNAME=$(echo $FILE|sed s/’….’/_/); mv -v $FILE $NEWNAME; done
for FILE in $(find . -type f -name ‘*…*’); do NEWNAME=$(echo $FILE|sed s/’…’/_/); mv -v $FILE $NEWNAME; done
for FILE in $(find . -type f -name ‘*..*’); do NEWNAME=$(echo $FILE|sed s/’..’/_/); mv -v $FILE $NEWNAME; done
for FILE in $(find . -type f -name ‘*_.*’); do NEWNAME=$(echo $FILE|sed s/’_.’/./); mv -v $FILE $NEWNAME; done

### Trocar os traços sobrando por vazio
for FILE in $(find . -type f -name ‘*__________*’); do NEWNAME=$(echo $FILE|sed s/’__________’/_/); mv -v $FILE $NEWNAME; done
for FILE in $(find . -type f -name ‘*_________*’); do NEWNAME=$(echo $FILE|sed s/’_________’/_/); mv -v $FILE $NEWNAME; done
for FILE in $(find . -type f -name ‘*________*’); do NEWNAME=$(echo $FILE|sed s/’________’/_/); mv -v $FILE $NEWNAME; done
for FILE in $(find . -type f -name ‘*_______*’); do NEWNAME=$(echo $FILE|sed s/’_______’/_/); mv -v $FILE $NEWNAME; done
for FILE in $(find . -type f -name ‘*______*’); do NEWNAME=$(echo $FILE|sed s/’______’/_/); mv -v $FILE $NEWNAME; done
for FILE in $(find . -type f -name ‘*_____*’); do NEWNAME=$(echo $FILE|sed s/’_____’/_/); mv -v $FILE $NEWNAME; done
for FILE in $(find . -type f -name ‘*____*’); do NEWNAME=$(echo $FILE|sed s/’____’/_/); mv -v $FILE $NEWNAME; done
for FILE in $(find . -type f -name ‘*___*’); do NEWNAME=$(echo $FILE|sed s/’___’/_/); mv -v $FILE $NEWNAME; done
for FILE in $(find . -type f -name ‘*__*’); do NEWNAME=$(echo $FILE|sed s/’__’/_/); mv -v $FILE $NEWNAME; done

echo “# Trabalho terminado !!! Bom trabalho!!!!”
) | zenity –progress –width 200 –height 100 –title “Informação do Sistema” –text “Informação do Sistema” –pulsate –auto-close


Fonte: http://www.revista.espiritolivre.org/conhecendo-o-nautilus-oitavo-script-tirando-espacos-e-padronizando-arquivos

0sem comentários ainda

    Enviar um comentário

    Os campos realçados são obrigatórios.

    Se você é um usuário registrado, pode se identificar e ser reconhecido automaticamente.

    Cancelar