Moving folder from a list

Hello!

Any help would be highly appreciated!

Newbie here, I would like to create the below workflow and I’m clueless of the correct activities to use. any inputs would be highly appreciated. Please note that the list is important as I need to use the same list for another activity to edit a config file that has the same name.

Workflow:

1- Get FOLDER name from a list (csv)
2- For each FOLDER name
3- Get FOLDER (source dir)
4- Move FOLDER (target dir)

Thank you very much in advance!

@GeoFixIT please find the solution inline
1- Get FOLDER name from a list (csv)
A- Read Csv - datatable use for each row
2- For each FOLDER name
A- for each row get a address column value this will be the folder name
3- Get FOLDER (source dir)
4- Move FOLDER (target dir)
Use

Thanks Arpit for the response, however the Roboyo - Copy download links are corrupted, appreciate further advise bro!

Thank you so much!

1 Like

@GeoFixIT Here you can have a variety of solution
Move Folder to another Folder

@GeoFixIT - the whole process can be done with 3 activities.

1. Read CSV activity  //  save as datatable variable i'll call dt1
2. For Each Row activity  // input = dt1
3. Move File activity  //  Path = row.item("YourColumnNameHere").ToString   //  Destination = YourTargetDirAsString

Hello Dave,

Thank you for the inputs, How can I define the source directory that I want to copy from the activity you shared? I’m getting the attached error:

I am sorry I just re-read and completely misunderstood. I thought you were moving files, but you are moving directories. Are these empty directories? Or do you want to move the folder + all files + all subfolders/files?

I’ll make the assumption you want to move everything, similar to a user cutting + pasting. To do that you need to replace the Move File activity with the Invoke Method activity.
TargetType = System.IO.Directory
TargetObject = leave this blank
MethodName = Move
Paramaters (2 of them):
#1: Direction = in // Type = String // Value = row.item(“YourColumnNameHere”).ToString
#2: Direction = in // Type = String // Value = YourTargetDestinationHere

No worries Dave. I’m sorry for the confusion, yes you are correct, each directory contains files and subfolders that I needed to copy. I hope the below complete workflow will shed light, part of the workflow is to edit different file types with the same name as the source directory.

1- Get CR names (CR= FOLDER AND FILE NAMES)
2- For each CR name (CSV LIST)
3- COPY CR Folder (DEVELOPMENT)

**I will be using another activity to alter the below files inside the folder **
4- CR.dtsx
5- CR.py

6- Copy CR folder including files and subfolders to PRODUCTION directory.

Can I still use CSV activity on the updated workflow you provided ?

Thanks,
Edmar

@GeoFixIT I’m not sure I understand. So the CSV has file names AND folder names? If so, you need to determine a way to only get the folder names. One way would be to use a datatable.Select or a lambda expression to get folder names only (for example you could exclude anything ending in a file extension such as .?? or .??? where ? is the wildcard allowing substitution of any 1 character)

A linq/lambda expression to grab directories only from a datatable containing strings with both directories and files could be:
dt1 = dt1.AsEnumerable.Where(function (x) x.Item("YourColumnName").ToString like "*.??" OrElse x.Item("YourColumnName").ToString like "*.???").CopyToDataTable

The Move Directory method I outlined above in the Invoke Method activity would work to transfer the directory and all files within. Parameter #1 is the source directory where the folder is currently located. Parameter #2 is the destination where you want the folder to be moved. All files found within the source directory will be moved.

You will need some recursive function to do this properly and you really dont want to use MOVE as any errors can make you loose files, so the better approach is to copy and after all is good, delete the source. Let me know if you need help in building this. Here it is: CopyFolder.xaml (12.2 KB)
And for safety the above just do the copy part, doesnt delete the source folder in the end.

2 Likes

@Dave, Thank you for all the inputs.

@bcorrea,

Thank you for your assistance, you are right, I would prefer to use a copy activity, however, I tried to open the CopyFolder.xaml you provided and it seems some of the activities in my studio are missing, I’m currently using Studio Pro 2020.6.0-Beta.93, please find the below error, appreciate any advise.

In truth they are not missing, cause i did not use any special one, this is just version issues and have an easy fix, just hit the toolbar button Manage Dependencies and fix it from there.