- Notas de Versão
- Introdução
- Tutoriais
- Projetos de automação
- Criando automações
- Noções básicas de automação
- Repo. de Objetos
- Melhores Práticas de Automação
- Tutorial: Criando uma Tabela Pivot
- Tutorial: Iterando através das Linhas de uma Tabela
- Tutorial: Comparar arquivos do Excel e enviar e-mails com erros de reconciliação
- Tutorial: Extrair dados de e-mails automatizados e movê-los para um aplicativo da área de trabalho.
- Tutorial: Filtrar dados no Excel
- Tutorial: Formatar células
- Tutorial: Adicionar informações sobre os arquivos de uma pasta para um arquivo do Excel
- Tutorial: Adicionando suas Próprias Fórmulas ao Project Notebook
- Automação do PowerPoint
- Automação de dados
- Atividades comuns
- Automação do Google Workspace
- Automação do OneDrive e do SharePoint
- Solução de problemas
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.
-
Etapa 1: Configurar um projeto e criar um arquivo do Excel na pasta do projeto.
- Create a new blank project using the default settings.
- Crie um arquivo do Excel na pasta do projeto e nomei-o como arquivos.xlsx.
- Abra o arquivo recém-criado no Excel e insira o texto
File Namena celula A1 e o textoFile Sizena célula B1. - Salve e feche arquivos.xlsx.
-
Etapa 2: Adicionar o arquivo do Excel ao projeto e indicar a pasta por cujos arquivos haverá a iteração.
-
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.
-
Na atividade Use Excel File:
- Click Browse
next to the Excel file field, and then browse to and select the file files.xlsx. - No campo Referenciar como, insira
FilesSizes.
- Click Browse
-
No painel Atividades, selecione a guia Arquivo, arraste a atividade For Each File in Folder e solte-a na atividade Use Excel File.
-
In the For Each File in Folder activity, click Browse
next to the Folder field, and then browse to and select a folder on your computer which contains files, for example the Desktop.
-
-
Etapa 3: copie as informações sobre os arquivos para o arquivo Excel.
-
No painel Atividades, selecione a guia Excel, arraste uma atividade Write Cell e solte-a dentro da atividade For Each File in Folder.
-
Na atividade Write Cell:
- Click Plus
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 Plus
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.
- Click Plus
-
Adicione uma segunda atividade Write Cell abaixo da primeira.
-
Na atividade Write Cell:
- Click Plus
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 Plus
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.
- Click Plus
-
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 Namepara a primeira atividade, eWrite Cell Sizepara a segunda. -
No painel Activities, arraste uma atividade Append Range e solte-a na atividade For Each File in Folder abaixo da segunda atividade Write Cell.
-
Na atividade Append Range:
-
Click Plus
on the right side of the Append after range field and then select FilesSizes > Sheet1. -
Click Plus
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.
-
-
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.
-