Copy only certain Files from a location to another


I ran into a bit of a problem in an automation i want to create and i didn’t manage to find a solution up to this point so i am hopping someone could give me a hand or “push” me in the right direction.

So, I have a large number of files (pdf) in a folder and i only want to move some of those files in another location. I know how to the get the files names and how to move them, the problem is that i don’t know how to make a condition in order to move only some of them based on a list i provide.

Anyone has any ideas i could try?

Thank you,

Hi @Cristian_Ionita ,

Use Contains in IF conditions and try to move the file.
If filename contains that keyword then move the file.

Hope it would solve the issue.


Hi ,

As shown in the below image, use directory.getFiles() and give your own pattern to move only those files


Hi Cristian,

first thought that crosses my mind is to create 2 loops - one nested into another. First loop takes file name (Guess that’s the critierium you want to follow) and in nested loop, look for the file and then move it to a desired folder :slight_smile:

thanks for the fast replies :smiley: I made more or less what you guys suggested and if i do it for all files or just one it works without a problem. The thing is that i need to move 1.000 files from a folder that contains 20.000 files, and i don’t know how and where to input those 1.000 file names in the process :frowning:

@Cristian_Ionita ,

I’d recommend using CSV or an Excel (xls, xlsx, xlsm) file. In the process you can simply read range from System/File/Workbook section (it allows programme to work in background) and create DataTable which subsequently will store all names

Hallo guys,

So I figured out a solution and thought i should share it, just in case anyone else is looking for something like this in the future - also, thank you for your suggestions - they helped me figure it our :smiley:

Assign "SourcePath = “your folder location”
Read range the list of files you want to move, with extension (Example: file.pdf) and store them in a table (i called mine “files”)
After that you use a “for each row in data table for files”, you assing “fullPath” to be "SourcePath + row(“FileName”).toString (FileName is the header of the source file) and add a copy file with From=FullPath" and the destination folder you want the files copied to.

Hope it helps and thanks again.

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