Move file from source to destination respective of filename

I want a file to move from one folder to another folder since My file names will vary after some particular name… i.e. abc.xlsx next day i.e. abs.xlsx or absdf.xlsx …so how the path can be written so that it will be moved from one folder to another…

Hi,

You can use Directory.GetFiles(“YourFolderName”) and get all the files from that folder to a list.

On the resultant list you can use For each loop and inside loop you can use Move File activity.

On top of that if you want to get only specific pattern files from the folder you can use as below:

Directory.GetFiles(“YourFolderName”, “abc*.xlsx”).ToList

Hi!

Check for the folder if that folder exist or not. If folder exists check for the files.

Follow the below steps…

  1. Take one Assign Activity. SourceFolder=“FolderPath”
  2. Take one Folder Exists Activity-Output-Bool_SourceExists
  3. Take one If Condition Bool_SourceExists=True
    Then
    check for the files
    Assign Arr_Files = Directory.GetFiles(SourceFolder,“*.xlsx”)
  4. Take one For each pass the Array of files
  5. Inside the body use move file Activity
    Source as Item Destination provide the Destination FolderPath.

Regards,
NaNi

@kjaiswal Refer Below .Xaml File.
Testing.xaml (7.6 KB)

Actually not getting what you explained can u clearly tell

Hi,

  1. First you can create a project with simple sequence
  2. Then drag an assign activity and in the Value section add the piece of code like Directory.GetFiles(“D:\Data”,“abc*.xlsx”).ToList and in the To Section create a List Variable (by clicking Ctrl+k)
  3. Now drag a For each Activity and pass the List variable you created in the previous step as input to it
  4. Inside For each you can drag a Move File Activity, in the Move File activity as destination you can use the item variable in the loop(which will have the entire path for the file) and in the destination you can use your destination folder

You can also refer to the xaml shared by @sb001


Getting this error…

Change the Type Argument to Array(String).

Remove the abc AS FILE NAME. You can give * If that File Names are dynamic.

Regards,
NaNi

I have to create Argument or variable for it?

The name is varying actually so I am not getting clear information

Variable!

Regards,
NaNi

Still getting same error…

Hello @kjaiswal

So your requirement is to move the file from one folder to another.

Suppose if you want to move from Folder A to folder B.

Is there only one file in the Folder A and that file you need to move to Folder B? Or in Folder A you have many files and you need to move only 1 file to Folder B?

Can you plz make it clear.

1 Like

Actually in one folder it will get downloaded daily in some particular format in abc…xlsx and It should moved from that folder to different folder…

In that file name will vary daily…

Follow the steps which is mentioned above!

Regards,
NaNi

Not working…

Show me the error!!

Can You explain Step by Step

@kjaiswal

So if you are moving the files daily only one file will be there during execution. Is that correct?