Advertisement
bls000

MesclarArquivosTXT

May 10th, 2020
1,928
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.58 KB | None | 0 0
  1. #Include <File.au3>
  2. #Include <Array.au3>
  3. #include <GuiToolTip.au3>
  4. #include <WinAPI.au3>
  5. #include <GUIConstantsEx.au3>
  6. #include <FontConstants.au3>
  7. #include <SendMessage.au3>
  8. #include <WindowsConstants.au3>
  9.  
  10. ;~ lista os arquivos no diretorio escolhido
  11. Global $FileList = _FileListToArray(@ScriptDir, "*.txt")
  12. ;~ caso não encontre exibe um erro
  13. If @Error = 1 Then
  14. BigToolTip("Não foram encontrados arquivos",2000,@DesktopWidth / 2 - 160,@DesktopHeight / 2 - 45,25)
  15.     Exit
  16. EndIf
  17.  
  18. If IsArray($FileList) Then
  19.    ;~ nome do arquivo de saida
  20.    $filename = 'out.txt'
  21.    $fileout = @ScriptDir & '\' & $filename
  22.  
  23.    ;~ verifica se o arquivo já existe e o exclui
  24.    if FileExists($fileout) then FileDelete($fileout)
  25.  
  26.    ;~ abre o arquivo para escrita
  27.    $file = FileOpen($fileout, 1)
  28.  
  29.    ;~ faz um loop pelos arquivos encontrados
  30.    for $i = 1 to $FileList[0]
  31.       If $FileList[$i] = $filename Then
  32.  
  33.       Else
  34.          $data = FileRead(@ScriptDir & "\" & $FileList[$i]) ; lê o arquivo encontrado
  35.          $data = StringRegExpReplace($data, '</p><p>', "") ;remove os tgs html de paragrafo
  36.          FileWrite($file, "~c -----" &  StringReplace($FileList[$i], ".txt", "")& "-----" & @CRLF) ;usa o nome do arquivo como titulo, removendo o .txt
  37.          FileWrite($file, $data & @CRLF) ;escreve o arquivo encontrado no arquivo de saida
  38.       EndIf
  39.    Next
  40.    FileClose($file) ;fecha o arquivo de saida
  41.    ShellExecute($fileout) ;abre o arquivo de saida
  42. Else
  43.    BigToolTip("Não foram encontrados arquivos",2000,@DesktopWidth / 2 - 160,@DesktopHeight / 2 - 45,25)
  44.    Exit
  45. EndIf
  46.  
  47.  
  48. #Region ### PopUp com fonte maior
  49. ;~ $btt_MSG = mensagem do popup
  50. ;~ $btt_Temp = tempo que a mensagem permanecerá em milisegundos
  51. ;~ $btt_Left = espaço da esquerda da tela
  52. ;~ $btt_Top = espaço do topo da tela
  53. ;~ $btt_Size = tamanho da fonte
  54.  
  55. Func BigToolTip($btt_MSG,$btt_Temp=1000,$btt_Left=@DesktopWidth / 2,$btt_Top=@DesktopHeight / 2,$btt_Size=22)
  56.    Local $hToolTip = _GUIToolTip_Create(0), $hDC = _WinAPI_GetDC(0)
  57.    Local $hFont = _WinAPI_CreateFont($btt_Size, 0, 0, 0, 800, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Tahoma')
  58.    Local $hOldFont = _WinAPI_SelectObject($hDC, $hFont)
  59.    _SendMessage($hToolTip, $WM_SETFONT, $hFont, True)
  60.    _GUIToolTip_AddTool($hToolTip, 0, $btt_MSG, 0, 0, 0, 0, 0, BitOR($TTF_TRACK, $TTF_ABSOLUTE)) ; <<<<<<<<<<<<<<<
  61.    _GUIToolTip_TrackPosition($hToolTip, $btt_Left, $btt_Top)
  62.    _GUIToolTip_TrackActivate($hToolTip, True, 0, 0)
  63.    Sleep($btt_Temp)
  64.    _GUIToolTip_Destroy($hToolTip)
  65. EndFunc
  66. #EndRegion ### END Koda GUI section ###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement