Moving files to another location reading excel

Hello,
I am new to Uipath, I have excel file with three columns as below
1-“empID”
2- “Dept”
3-“Location”

All employee files name empID are located in main directory.
I have to move each empID’s file to its relevant dept. folder (Location) based on column 2 (Dept).
Please help to find the solution.

Thanks in Advance.

@Sameer_S

Can you please show us some sample data. Need to see once how it will looks like in Excel file.

PF.xlsx (9.2 KB)

I have attached excel data, files names (EmpID) are in one main folder from where i need to move them to subfolders based on department.

Thanks

Hello @Sameer_S

I think your process is a typical RPA process.
At least, you need 3 steps to implement your process.
First, use the Read Range activity to get table data which includes three columns.
Second, use the For Each Row to get the values of three column from each row.
Third, use the Move File activity with empID and Location in For Each Row container to move file to each correct folder.

@Sameer_S

  1. Use Read Range activity to read the data from excel file and will give you output as DataTable. Let’s say InputDT.

  2. And then use For Each Row activity to iterate one by one row from DataTable.

  3. Inside the loop, use Move File activity and mention source and destination as below.

Source: Directory.GetFiles(“MainFolderPath”,row(“empID”).ToString+“*”)(0)
Destination: row(“Location”).ToString

Hi,

It might be better to use Dictionary as the following sample.

Sequence1.xaml (8.9 KB)

This assumes filename (without extesntion) is empID.

Regards,

@lakshman @wusiyangjia @Yoichi
Thanks for the reply, please note i need to move employee’s files(column “empID”) from Main Folder to their Department’s folder based on excel column #2 (column “Dept”). The department folder path mentioned in column 3 (“Location”).
Thanks.

@Sameer_S

Did you try above mentioned steps ?

@lakshman
Thanks for the help…

I did as you mentioned , but getting error "Index was outside the bounds of the array.

"


BOT err.txt (1.7 KB)

Thank You,
Sameer

@Sameer_S

I guess we don’t have any matching file with that name in that specified location because of that you are getting that error.

@lakshman

Excel data file in located in “C:\Passport BOT\FR.xlsx”
File to be moved to other folders which path is mentioned in excel.

It is giving error as " Move File: Index was outside the bounds of the array"

Try adding log to check if file exist

@ahmad_C ,

Thanks for responding ,
All files exist mentioned in excel,

Getting array error with Move File with For Each Row activity.

Thanks

@lakshman ,

It moves only first file then giving error " Move File: Index was outside the bounds of the array"

@Sameer_S

Use Try Catch block activity and keep Move File activity inside Try block and in Catch block use Log Message activity to print the error message.

@lakshman ,

I am getting same error “Move File: Index was outside the bounds of the array”.

I have multiple pdf files( "empID1 ,"empID2 , "empID3, “empID4” etc) in common folder.
I need BOT to read excel column “empID” and move the pdf file from common folder to the path mentioned in Column “Location”.

As per below code it moves only 1st file to its correct location and then throws the error msg. as “Move File: Index was outside the bounds of the array

Directory.GetFiles(“MainFolderPath”,row(“empID”).ToString+“*”)(0)

Pleas help to fix this issue,

Thanks
Sameer