Advertisement
adaoduque

Mover arquivos de imagens para projeto Android

Jan 24th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.52 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #####################################################################
  4. #   Extrai os arquivos de imagens baixados em arquivos .zip para o  #
  5. #           diretório padrão do Android em seu projeto              #
  6. #                                                                   #
  7. #   Dependências: unzip                                             #
  8. #                                                                   #
  9. #   Programador: Adão Duque                                         #
  10. #   Contato: adaoduquesn@gmail.com                                  #
  11. #   Data: 2017-01-24 12:01                                          #
  12. #                                                                   #
  13. #                                                                   #
  14. #####################################################################
  15.  
  16. #path to file icons
  17. localFileZip=""
  18.  
  19. #name project
  20. nameProjet=""
  21.  
  22. #Folder to extract file tmp
  23. tmp="/tmp/Ks76H1m/"
  24.  
  25. #path to folder images
  26. pathFolder="/app/src/main/res/"
  27.  
  28. #path to android studio projects
  29. toSave="/home/$USER/AndroidStudioProjects/"
  30.  
  31. #Path full com project name and folder
  32. fullPath=""
  33.  
  34. #/home/adao/AndroidStudioProjects/UltraPet/app/src/main/res/
  35.  
  36. echo -n "\nDigite o local do arquivo de imagens > "
  37. read localFileZip
  38.  
  39. echo -n "\nDigite o nome do projeto android > "
  40. read nameProjet
  41.  
  42. echo "\nProcessando..."
  43.  
  44. #Verifica se o diretorio do projeto existe
  45. if [ -d "$toSave$nameProjet$pathFolder" ]; then
  46.  
  47.     #Obtem o full path do projeto
  48.     fullPath=$toSave$nameProjet$pathFolder
  49.  
  50.     #Verifica se o arquivo existe
  51.     if [ -f "$localFileZip" ]; then
  52.  
  53.         fileWithExtension="${localFileZip##*/}"
  54.  
  55.         fileName="${fileWithExtension%%.*}"
  56.  
  57.         #Cria o diretório temporário
  58.         mkdir $tmp
  59.  
  60.         #Copia o arquivoo para o diretório temporário
  61.         cp $localFileZip $tmp
  62.  
  63.         #Go to diretory
  64.         cd $tmp
  65.  
  66.         #Extract file
  67.         unzip $fileWithExtension
  68.  
  69.         clear;
  70.  
  71.         echo "\nMovendo Arquivos";
  72.  
  73.         #Go to new directory created
  74.         cd $fileName;
  75.  
  76.         #Go to directory in folder
  77.         cd "android"
  78.  
  79.         #Copy all files
  80.         cp drawable-hdpi/* $fullPath"mipmap-hdpi"
  81.  
  82.         cp drawable-mdpi/* $fullPath"mipmap-mdpi"
  83.  
  84.         cp drawable-xhdpi/* $fullPath"mipmap-xhdpi"
  85.  
  86.         cp drawable-xxhdpi/* $fullPath"mipmap-xxhdpi"
  87.  
  88.         cp drawable-xxxhdpi/* $fullPath"mipmap-xxxhdpi"
  89.  
  90.         #Remove dir temporary
  91.         rm -rf $tmp
  92.  
  93.         echo "\nFeito!!!\n"
  94.  
  95.     else
  96.         echo "\nError: File $localFileZip doesn't exists"
  97.     fi
  98.  
  99. else
  100.     echo "\nError: Directory $toSave$nameProjet$pathFolder doesn't exists"
  101. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement