Inserting every file path of a folder into an existing excel column's rows

As there are multiple files in folder, I need to insert each file’s path into an existing excel column’s row.
like if there are 3 files in a folder and their paths are c/1.jpg,c/2.jpg,c/3.jpg then under the File path column each row will be filled up by those path accordingly.

@nibir08,

Check this xaml, it may help you. It will all the file types and extract it names to a datatable, then it will be written into an excel file.

If you want to get only specified types of files then check the commented out part for filtering files.

ExcelFileNamesToExcel.xaml (10.0 KB)


can you please check this out? i tried to solve it in this way

1 Like

@nibir08

Hope you wrote expression like this.

    strpath [] = Directory.GetFiles("FolderPath",searchoption.AllDirectories)

And also declare one interger variable named index and intialize with 2

In Write Cell activity, mention Range as “F”+index.Tostring

After write cell activity, increment index value by 1 using Assign activity.

    index = index+1
2 Likes

Yah this would work work either
You were almost done
—ensure that the type argument property of for each loop is set to String
But make sure that in range of write cell mention as
“F”+counter.ToString
Where counter is a variable of type int32 with default value as 2 defined in the variable panel
—and in the input value mention as item.ToString so that it will write the filepath in that cell position
—next to this write cell activity use a assign activity to increment this counter value
counter = counter + 1

Cheers @nibir08

2 Likes

@nibir08,

What is the “showPath” variable holds?

Actually you have to use item.Tostring in that place to write the file path in the cell.

Have you checked the xaml, which I have attached in my previous reply in this post?

I’ve checked the xaml file you provided. showpath was a typo actually. i’m trying accordingly

i’m just getting the 1st file path not all of them
here i’m attaching my .xaml file
Main.xaml (7.5 KB)

I’m not understanding the directory command.
My files are in lets say C/demo/newfolder and i want get all the path directory of files in that folder. so how can i do that.
in my method i get only one file as in excel column.

@nibir08,

Check like the below one,

1 Like

can not change the variable type listofFiles to list

@nibir08,

It is already a List → List(Of FileInfo).

Do you need it in List(Of String)?

Main.xaml (7.6 KB)

can you please check it?

@nibir08,

Main (4).xaml (7.5 KB)

Check the updated workflow.

To declare a List type you have to select the type as shown in the image.

Untitled

I solved it. :smiley:
Thanks a lot for helping me out :smiley:

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