Search all excel files in folder for keyword, then if they have the key word move to a different folder

Hello,

I’m looking to search all excel files in a folder for a list of keywords, then if they match the word, copy or move it to another folder.

Any help is appreciated

hi
hope these steps would help you resolve this
–use a assign activity like this
arr_filepath = Directory.GetFiles(“yourfolderpath”,“*.xlsx”)
where arr_filepath is a variable of type array of string
–then use a FOR EACH activity and pass the above variable as input and change the type argument as string in the property panel
–inside the loop use a IF condition like this
item.ToString.Contains(“yourkeyword”)
if true it will go to THEN part where we can use MOVE FILE activity where inthe source mention as item and in the destination mention the folder path where we want to move as a string

Cheers @sparkplug93

Hello,

I’m not receiving errors but the files are not moving. What could possibly be the cause?

can i have a view on the workflow if possible
@sparkplug93

Capture

The files are excel files. I ran it twice, once with the “*.xlsx” at the end of the directory

1 Like

Fine
can i have a screenshot of the property panel of MOVE FILE activity if possible
Cheers @sparkplug93

Capture2

Thank you

sorry for the delay
i would like to know the value of PATH and DESTINATION property
and also ensure that this condition is correct
may be trywith this
item.ToString.ToUpper.Contains(“NORTH”)

Cheers @sparkplug93

1 Like

You dont need the IF inside, just change this:
arr_filepath = Directory.GetFiles(“yourfolderpath”,“asterisknorthasterisk.xlsx”)

path is the same folder as directory.getfile(“C:\Users\MichaelC\Desktop\Excel examples”)
Destination (“C:\Users\MichaelC\Desktop\Excel hits”)

1 Like

we need to mention the file path buddy
like this
that is in PATH property mention as item.tostring
and in the desination mention as “C:\Users\MichaelC\Desktop\Excel hits”+“\”+Path.Getfilename(item.tostring)

Cheers @sparkplug93

1 Like

Sorry for being a pain. It’s still not working. could this be do to them being excel files

The destination can be only a folder path if he doesn’t need to change the file name…

1 Like

What route would you reccomend

I would assume that you have the wrong variable in the From Path of your Move File activity, you have to use “item” there…

you were almost done
in move file activity in the PATH PROPERTY mention the folder path along with the file name that is directly mention as item.tostring as item is the one that holds the file path now being inside the for each activity
and in the destination property mention the folder path alone (as you did already) where we want to move the file

Cheers @sparkplug93

Capture3

1 Like

till .tostring is enough buddy
no need of that (“schedule”) remove that pls
it should be like this
just
item.ToString
as item is the variable now holding the filepath so we dont need to mention it @sparkplug93

It’s still not working. Should I convert it to a word document first?

may i know what was the error and why do we need to convert it as a word document while we are processing excel file
@sparkplug93