bls000

Listar Imagens 0.4b

May 10th, 2020
1,667
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Array.au3>
  2. #include <MsgBoxConstants.au3>
  3. #include <File.au3>
  4. #include <String.au3>
  5.  
  6. Global $pastaRaiz = @ScriptDir
  7. Global $proXpastaDaBuscaAtual
  8. $ListadePastas = _FileListToArray($pastaRaiz, "*", $FLTA_FOLDERS)
  9.  
  10. For $i=1 To $ListadePastas[0]
  11. ;~    buscando imagens nas pastas encontradas
  12.       Global $pastaDaBuscaAtual = @ScriptDir & '\' & $ListadePastas[$i]
  13.  
  14. ;~    cria um link para proxima pasta na lista de pastas
  15.       $r = $i+1
  16.       If $r > $ListadePastas[0] Then
  17.             $proXpastaDaBuscaAtual = @ScriptDir & '\' & $ListadePastas[$i]
  18.       Else
  19.             $proXpastaDaBuscaAtual = @ScriptDir & '\' & $ListadePastas[$r]
  20.       EndIf
  21. ;~    ConsoleWrite('!Buscando Imagem na Pasta: ' & $pastaDaBuscaAtual & @CRLF)
  22.  
  23. ;~    lista as imagens encontradas na pasta
  24.          ConsoleWrite($pastaDaBuscaAtual & @CRLF)
  25.       Global $ListaDeImagensAtual = _FileListToArrayRec($pastaDaBuscaAtual, "*.jpg;*.png;*.jfif", $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_SORT,$FLTAR_NOPATH)
  26.       ConsoleWrite(_criarListaParaConsole($ListaDeImagensAtual) & @CRLF)
  27.  
  28. ;~    cria o HTML com a galeria de imagens
  29.       escreverHtml($ListaDeImagensAtual, $pastaDaBuscaAtual)
  30. Next
  31.  
  32.  
  33. Func escreverHtml($ListaDeImagensAtual, $EndDaPasta)
  34. ;~    cria um html dentro da pastacom as imagens
  35.    $caminhoDoHtml = $pastaDaBuscaAtual & '\' & LastElement($EndDaPasta) & ".html"
  36.  
  37.    $GaleriaDentroPasta = FileOpen($caminhoDoHtml, $FO_OVERWRITE)
  38.  
  39.    ;~ escreve o cabeçalho do arquivo html
  40.       FileWrite($caminhoDoHtml, "<!DOCTYPE html><html lang='pt-br'><head><meta charset='utf-8'/><meta content='width=device-width, initial-scale=1, maximum-scale=1' name='viewport'>" & @CRLF & '<title>' & LastElement($EndDaPasta) & '</title>')
  41.  
  42.    ;~ escreve a linha com o css
  43.       FileWrite($caminhoDoHtml, "<style type='text/css'> /*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */button,hr,input{overflow:visible}progress,sub,sup{vertical-align:baseline}[type=checkbox],[type=radio],legend{box-sizing:border-box;padding:0}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0; width:100%}details,main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:ButtonText dotted 1px}fieldset{padding:.35em .75em .625em}legend{color:inherit;display:table;max-width:100%;white-space:normal}textarea{overflow:auto}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}[hidden],template{display:none}.btn a:link,a:visited{background-color:#f44336;color:#fff;padding:14px 25px;text-align:center;text-decoration:none;display:inline-block}.btn a:hover,a:active{background-color:red}" & @CRLF & '</style>' & @CRLF & '</head><body>' & '<center><h1>' & LastElement($EndDaPasta) & '</h1>')
  44.  
  45.    ;faz um loop pela lista de imagens e coloca no html
  46.    For $y=1 To $ListaDeImagensAtual[0]
  47.       FileWrite($caminhoDoHtml, "<img class='' src='" & $ListaDeImagensAtual[$y] & "' width='800'>" & @CRLF)
  48.    Next
  49. FileWrite($caminhoDoHtml, "<br><p class='btn'> <a class='' href='..\" & LastElement($proXpastaDaBuscaAtual) & "\" & LastElement($proXpastaDaBuscaAtual) & ".html'>" &  LastElement($proXpastaDaBuscaAtual) & "</a></p>" & @CRLF)
  50. FileWrite($caminhoDoHtml, "</center></head><body>")
  51. EndFunc
  52.  
  53. Func LastElement($lst)
  54.    $aArray1 = _StringExplode($lst, "\", 0)
  55.    Return $aArray1[UBound($aArray1)-1]
  56. EndFunc
  57.  
  58.  
  59. ;~ função mostrar array em forma de lista
  60. Func _criarListaParaConsole($CLPC)
  61. Local $quant = UBound($CLPC)-1
  62. Return _ArrayToString($CLPC, ', ', 1, $quant)
  63. EndFunc
RAW Paste Data