How to tranfer file to folder

I have multiple folder path in excel
Ex:
/home/DT/Country
/home/AT/State
/home/DU/Area
/home/SR/Street

If file name consists of DT then file need to move to /home/DT/Country
If file name consists of AT then file need to move to /home/AT/State

@Meghana_Bonu1,

Welcome to the UiPath Community :tada:

You can use one mapping file with keyword and their destination folder path. While iterating files, you can check for the initial and get the folder path accordingly.

Thnaks,
Ashok :slight_smile:

Hello @Meghana_Bonu1

So I suggest the following way

  1. Create a dictionary ( you can put it on config)
    KEY : DT — VALUE: folder_path

2.Iterate for item, to iterate for each file_path.
3. split the file_path by “\” and get last , in order to get just the filename
4. Check the filename contains one of the Words you want it to contain.
5. Based on which contains it do a move file with the location folder_path+“\”+filename

@Meghana_Bonu1

Welcome to the community

  1. Read the excel into datatable dt
  2. You can use for each file in folder activity…
  3. Inside that use if condition to check if currentfile.name contains AT etc …you can use a switch case or if
  4. Depending on what is present…decide the folder and use move file

Cheers

@Meghana_Bonu1

  1. Use the Excel Application Scope activity to read the Excel file.
  2. Use the Read Range activity to read the data from the Excel file into a DataTable.
  3. Use a For Each Row activity to iterate through each row in the DataTable.
  4. Inside the loop, use an Assign activity to get the folder path and keyword from the current row:
    folderPath = row(“Folder Path”).ToString()
    keyword = row(“Keyword”).ToString()*
  5. Use the Directory.GetFiles method to get the list of files in the source directory.
  6. Use a For Each activity to iterate through each file in the source directory.
  7. Inside the loop, use an If activity to check if the file name contains the keyword:
    If fileName.Contains(keyword)
  8. If the condition is true, construct the destination folder path using the folderPath variable:
    destinationPath = Path.Combine(folderPath, Path.GetFileName(fileName))
  9. Use the Move File activity to move the file to the destination folder:
    Source = fileName
    Destination = destinationPath