Advertisement
KeplerBR

Renomeador v1.0

Oct 28th, 2012
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.68 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. # Renomeador v1.0
  4. # * KeplerBR (28/10/2012 16:00) :
  5. #   - Released!
  6. #
  7. # [EN]
  8. #  Rename automatically the images of the cards of the game Ragnarok.
  9. #  Be included num2cardillustnametable.txt and images of the card in the same directory!
  10. #  Both of you get through the GRF Tool.
  11. #  Easily adaptable to other rename files based on a text file.
  12. # [PT-BR]
  13. #  Renomear automaticamente as imagens das cartas do jogo Ragnarok.
  14. #  Tenha incluído o num2cardillustnametable.txt e as imagens da carta no mesmo diretório!
  15. #  Ambos você consegue através do GRF Tool.
  16. #  Facilmente adaptável para renomear outros arquivos com base em um arquivo de texto.
  17. # ------------------
  18. # By KeplerBR
  19.  
  20. # Definindo variáveis
  21. use strict;
  22. use warnings;
  23.  
  24. sub renomear() {
  25. my (@separado, @listaErros);
  26. my $linhaAtual = 0;
  27.  
  28. # Rotina para renomear
  29. open(my $arq,'num2cardillustnametable.txt');
  30.     while(<$arq>)
  31.     {
  32.     $linhaAtual++;
  33.         chomp;
  34.         if ($_ ne "") {
  35.             @separado = split(/#/);
  36.             $separado[0] = $separado[0] . '.bmp';
  37.             $separado[1] = $separado[1] . '.bmp';
  38.             if (-e $separado[1]) {
  39.                 rename ($separado[1], $separado[0]);
  40.                 print "[+] $linhaAtual: $separado[1] renomeado para $separado[0]\n";
  41.             } else {
  42.                 print "[!] $linhaAtual: Não foi encontrado o $separado[1]!\n";
  43.                 push (@listaErros, "[!] $linhaAtual: Não foi renomeado o $separado[1] para $separado[0]\n");
  44.             }
  45.         }
  46.     };
  47.  
  48. # Finalizando rotina
  49. print "\n\n";
  50. close($arq);
  51.     if (@listaErros == 0) {
  52.         print "[-] Renomeação concluída com sucesso!\n";
  53.     } else {
  54.         print "[-] Renomeação terminou com os seguintes problemas:\n";
  55.         print @listaErros;
  56.     }
  57. print "\n\n";
  58. system('pause');
  59. }
  60.  
  61. &renomear();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement