Move Folder to another Folder

where to write this code? in assignment statement? if you dont mind please provide me some sample .xaml

Thanks for your reply. This will complicate the process.I need to first create a new directory with the same name and move files one by one also internally it may contain sub folders also. So i feel this will complicate?

Correct me if I am wrong

As @sarathi125 suggested, Directory.Move method moves a directory and all its contents, including nested subdirectories and their files, to a new location and if the destination directory already exists, an error occurs.
You cannot use assign activity because return type of this method is none.
You can write this code in invoke method activity with the following options:

  1. Target Type as System.IO.Directory
  2. Method Name as Move
  3. Two parameters in property panel with In and String Type for SourceDirectory and DestinationDirectory.


Thanks for your reply

“Invoke Code” – is this the activity I need to use?
When i look at screen shot shot this looks like “Invoke Method” which will throw error since the destination diretiry already exist.

If you don’t mind please provide a sample .xaml

1 Like

Hello @sarathi125.
How can this be done?
Thank you so much,

hi Bharat,

i get an error as Source & destination path must have identical roots. Move will not work across volumes.

Could you please share some details about exactly what u r trying to do and the error u r facing,

i get an error as Source & destination path must have identical roots. Move will not work across volumes.

Am trying to move files in a folder located in share drive to local drive . It is copying the entire folder. unable to do it using move

Please check the XAML attached.
In Simple, we can’t move the folder. So I copied the source folder to destination and deleted the source. It works fine. Please check and confirmsample.xaml (5.1 KB)

1 Like

MoveDirectory.xaml (10.7 KB)

This will copy a directory and all its subsequent subdirectories and files to your chosen location. Just invoke this somewhere to copy the files and then delete the original folder. Or if you want to, you can replace the ‘Copy file’ activity with a ‘Move’ activity.

While moving the files from one folder to another folder, In this case the main folder files only moved to another folder not sub folder files - Please help me regarding this.
Example : C://Main folder files : Test_001, Test_002
Sub folder : C://Main folder files//Sub folder files : Test_001,Test_002

Welcome to uipath community
Yes buddy
Were you facing any issue in that
Cheers @suryaprakashm

Hi @Palaniyappan
Many files are in the same names, i need to move main folder files - So i search some file names and move the files from one folder to another folder, While moving the files all files moved, how to split the main folder files.

Hey ,I need to move folder with files to destination folder that does not exist but the challenge is i have to move into destination subfolder that does not exists.but when I try passing it in parameters in invoke method I get error saying that cannot find part of the file

Welcome to UiPath community
For that we need to first create a folder with CREATE DIRECTORY activity and then use either MOVE FILE or INVOKE METHOD to move the file

Cheers @Soumya587

Thank you,but we cannot use invoke method if we create directory and it will throw error saying that directory already exists

@Soumya587 Check this Workflow:
There are two Folders SourceFolder which contains Files and DestinationFolder where another Folder needs to be Created and Files from SourceFolder needs to be copied to this.
What the Workflow does is :

  1. Creates the Destination Folder with new Folder Name
  2. Gets the Files From Source Folder one by one and moves it into the Destination Folder Created.
  3. Deletes the SourceFolder

In this way Moving the Folder with Files can be achieved, This is one way I Implemented, but there might be other ways. Hope it helps :sweat_smile:
Try running the workflow and Tell me if it works (109.5 KB)

1 Like

Thank you so much that was helpful,I have implemented in the other way around and it worked

1 Like

Thanks supermanPunch! It’s works for me! Greetings

1 Like