How to get file paths to excel

I am trying to create a automation to list all the path location names from a file server for example .pdf documents and list these to excel. How can I write the path location names to an excel file?

Hi @Peter_Raats
Can Use this Syntax

Directory.GetFiles(“Youe Folder Location”).ToArray

After adding it into array you can add it into datatable

Add into datatable by using the below syntax

ArrStr.Select(Function(a) DT1.LoadDataRow({a},False)).copytodatatable

It Helps!

@Peter_Raats

Directory.GetDirectories (to list directories)
For Each item In Directory.GetDirectories
Directory.GetFiles with filter “*.pdf”
- For Each pdfFile In Directory.GetFiles
- Add pdfFile to DataTable
Excel Application Scope
- Write Range

OR

String.Join(“,”,Directory.GetFiles(“FolderPath”,“.*pdf”,SearchOption.AllDirectories).ToArray)

Hi @Peter_Raats

Try this:
This will get all the pdf file paths in the directory to an array.
pdfFiles = Directory.getfiles(YourDirectoryPath, "*.pdf", SearchOption.AllDirectories)

Build Data Table (Create DataTable)
Add Data Column (Add Column Name)
For Each through file paths array
            Add Data Row (Add Paths to DataTable)
Write Range (DataTable to Excel)

Hi @Peter_Raats

You can use for each file in folder, in that you filter it by any type

In the for each you can use excel activites like excel application scope and write range to write it in excel

Hi
Try this

Sequence
Assign files = Directory.GetFiles(“YourServerPath”, “*.pdf”) // Get a list of .pdf files

Build Data Table
    Output: dataTable (Create a DataTable with a "Path" column)

For Each (file in files)
    Add Data Row
        Input: {file}
        DataTable: dataTable

Write Range
    Input: dataTable
    WorkbookPath: "YourExcelFilePath.xlsx"
    SheetName: "Sheet1" (Specify the desired sheet name)

Thank you

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.