UiPath Documentation
studiox
2023.4
false
Guia do usuário do StudioX
Importante :
A localização de um conteúdo recém-publicado pode levar de 1 a 2 semanas para ficar disponível.

Tutorial: Adicionar informações sobre os arquivos de uma pasta para um arquivo do Excel

Neste tutorial, criaremos uma automação que recupera o nome e o tamanho de todos os arquivos em uma pasta e adiciona essas informações a um arquivo Excel.

Vamos criar um projeto e começar adicionando uma atividade Use Excel File para indicar o arquivo Excel a ser usado. Em seguida, adicionaremos uma atividade For Each File In Folder para indicar a pasta de onde será recuperada a informação de arquivo. Dentro de For Each File in Folder, adicionaremos duas atividades Write Cell , uma para copiar o nome, outra para copiar o tamanho de cada arquivo para duas células no bloco de anotações do projeto. Terminaremos adicionando uma atividade Append Range que anexa as duas células para um intervalo em um arquivo do Excel após as células serem preenchidas para cada arquivo.

  1. Etapa 1: Configurar um projeto e criar um arquivo do Excel na pasta do projeto.

    1. Create a new blank project using the default settings.
    2. Crie um arquivo do Excel na pasta do projeto e nomei-o como arquivos.xlsx.
    3. Abra o arquivo recém-criado no Excel e insira o texto File Name na celula A1 e o texto File Size na célula B1.
    4. Salve e feche arquivos.xlsx.
  2. Etapa 2: Adicionar o arquivo do Excel ao projeto e indicar a pasta por cujos arquivos haverá a iteração.

    1. No StudioX, no painel Atividades, selecione a guia Excel e clique duas vezes em Use Excel File. Uma atividade Excel File é adicionada ao painel do designer.

    2. Na atividade Use Excel File:

      • Click BrowseImagem dos documentos next to the Excel file field, and then browse to and select the file files.xlsx.
      • No campo Referenciar como, insira FilesSizes.
    3. No painel Atividades, selecione a guia Arquivo, arraste a atividade For Each File in Folder e solte-a na atividade Use Excel File.

    4. In the For Each File in Folder activity, click Browse Imagem dos documentos next to the Folder field, and then browse to and select a folder on your computer which contains files, for example the Desktop.

  3. Etapa 3: copie as informações sobre os arquivos para o arquivo Excel.

    1. No painel Atividades, selecione a guia Excel, arraste uma atividade Write Cell e solte-a dentro da atividade For Each File in Folder.

    2. Na atividade Write Cell:

      • Click PlusImagem dos documentos on the right side of the What to write field, and then select CurrentFile > Name to indicate that we want to copy the name of the current file in the iteration.
      • Click PlusImagem dos documentos on the right side of the Where to write field, and then select Project Notebook (Notes) > Indicate in Excel to open the Project Notebook. In the file, select the A1 cell in the Scratchpad sheet, and click Confirm in the UiPath tab in the Excel ribbon. You have indicated that you want to paste the name of the current file in the iteration to cell A1 in the Scratchpad sheet of the Project Notebook.
    3. Adicione uma segunda atividade Write Cell abaixo da primeira.

    4. Na atividade Write Cell:

      • Click PlusImagem dos documentos on the right side of the What to write field, and then select CurrentFile > Size to indicate that we want to copy the size (in bytes) of the current file in the iteration.
      • Click PlusImagem dos documentos on the right side of the Where to write field, and then select Project Notebook (Notes) > Indicate in Excel to open the Project Notebook. In the file, select the B1 cell in the Scratchpad sheet, and click Confirm in the UiPath tab in the Excel ribbon. You have indicated that you want to paste the size of the current file in the iteration to cell B1 in the Scratchpad sheet of the FilesSizes Excel file.
    5. Para tornar as duas atividades Write Cell mais facilmente identificáveis, edite o nome na barra superior de cada uma. Por exemplo, utilize Write Cell Name para a primeira atividade, e Write Cell Size para a segunda.

    6. No painel Activities, arraste uma atividade Append Range e solte-a na atividade For Each File in Folder abaixo da segunda atividade Write Cell.

    7. Na atividade Append Range:

      • Click PlusImagem dos documentos on the right side of the Append after range field and then select FilesSizes > Sheet1.

      • Click Plus Imagem dos documentos on the right side of the What to append field, and then select Project Notebook (Notes) > Indicate in Excel to open the file in Excel. In the file, select the A1:B1 cells and click Confirm in the UiPath tab in the Excel ribbon. You have indicated that you want to add the information about the current file in the iteration to columns A and B in the FilesSizes file after the existing data in the file.

    8. Clique em Salvar na faixa de opções do StudioX para salvar a automação e, então, clique em Executar para executar a automação.

      O nome e o tamanho de cada arquivo na pasta indicada são copiados um por um para as células A1 e A2 na planilha do Scratchpad do Notebook do projeto e, a seguir, anexados a arquivos.xlsx.

Esta página foi útil?

Conectar

Precisa de ajuda? Suporte

Quer aprender? Academia UiPath

Tem perguntas? Fórum do UiPath

Fique por dentro das novidades