Copy multiple files from one location to another location

hi,
i have one folder in D:drive like folder name “Rpa” in that i have multiple files like .pdf,.xlsx,.doc.
i want copy particular .pdf files copy to E:Drive “Backup” folder.
how can do it ?

@Anand_Designer

Install below component from Uipath GO and then use Move Files activity and specify "*.pdf** in it to move all pdf files from source to destination path.

https://go.uipath.com/component/file-activities

Hi @Anand_Designer
use Directory.getFiles(InputFilePath,“*.pdf”)
and use for each item in StrDirectoryarray
and then use Move file activity

Thanks
Ashwin S

Hi @Anand_Designer

What you have to do is, first you need to get the list of files that you need to move from the source folder…

Directory.GetFiles("D:\RPA\", "*.pdf")

This code will give you all the pdf files in the given folder path… The output of this will be a string array that holds the full file path for each file

Next, use a For Each activity to loop through the items in the array. Set the argument type of the For Each activity to String.

Within the for each loop, place a move file activity. In this activity, for the source path, provide item.ToString which contains the file path for the file you want to move.

For the destination, Provide the destination folder path along with the file path that you can take from the file path of item variable like this

"E:\Backup\" + Path.GetFileName(item.ToString)

This will move the files one by one

1 Like

@Anand_Designer

You can get the names of all the files when you use for loop and give in the folder name…

For each file in (“YourFolderPath”)
{
if (fileName).tostring.contains(“.pdf”)
{
Move file (Input: Source and Destination)
}
}

This way you can easily move the PDF files from one location to other…

Thanks and regards,
@hacky

hi,
i don’t want to move files i want copy only.

Hi @Anand_Designer
Use Copy file and pass the item like (“D:\RPA",”*.pdf")

Thanks
Ashwin S

Hi @Lahiru.Fernando
Thanks its working .

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