Search for excel file inside a folder

Hi,

How can I search for particular excel file inside a directory?
Excel search
I need to find File3.xlsx and copy it to another folder

Use Copy file Activity and then pass source and destination path in it

1 Like

For checking is file available/present in that folder or not then before copy use path exist and pass full path of that file and then use if activity if path exist is true then use copy file

2 Likes

What exactly do you mean? If you know you want file3.xlsx and you know the directory it’s in, then you already know the full path of the file? Path.Combine(Directory,FileName) will give you a string that is the full file path of the file.

If you know the parent directory, but not the subdirectory then you can use Directory.GetFiles() method to search for that specific file in all subdirectories like so: Directory.GetFiles(YourPath,"File3.xlsx",SearchOption.AllDirectories)(0)

1 Like

Hi @Dave

Great to hear from you again :slight_smile:
I am actually continuing automation of process from this topic:

I have folders as in pic:
Folders_new
I have list of excel files in folder 08.2020:
Excel search
Now I need to find one particular excel file File3.xlsx and copy it to folder 09.2020
How can I do that?
I am continuing that process you sent me several hours ago :slight_smile:

1 Like

@Dave
the process you sent me is delete.xaml (7.1 KB)
now I am continuing it

You can utilize the ‘copy file’ activity that @ImPratham45 mentioned. Source is where the file is currently located (full file path including extension) and Destination is where you want to move the file to (full file path including extension)

Let us know if you are still having further troubles after trying to use that activity

1 Like

Folders in the directory will be updated each month, I mean new folder will be added each month and file from previouse month should be copied to new created folder. Folder 08.2020 is given as an example. For copying file I can not use fixed link and need to create variable that stores last folder name (in this case 08.2020) which will be new each month.
I created variable LastMonth = NameListDates.max().tostring(“MM.yyyy”)
and used “Copy file” activity as you advised
However in the “From” filed I could paste this command: Path.Combine(YourPath,LastMonth) and don’t know how to indicate File3.xlsx


Which command should I add to select File3.xlsx from last available folder?

Just add the file name to the path.combine() portion. So it would be Path.Combine(YourPath,LastMonth,"file3.xlsx") and Path.Combine(YourPath,NewFolderName,"file3.xlsx")

You can use a write line activity while developing to help validate that it is showing the correct ‘from’ and ‘to’ paths if you are still having trouble - this will help ensure that you are getting the correct file paths

1 Like

@Dave
Thank you very much Dave! It worked :+1:

1 Like

@ImPratham45
Thank you too!

1 Like

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