Create 200 folders and files

Hi All,

I have a scenario where I have to create 200 folders and 100 files within each of those 200 folders.

I know there are activities to create folders and files in UiPathm, but it will take a very long time if we have to create many using those activities.

Is there any other better route to do this?

@Krithi1

During runtime it shpuld be fast only

Also if the files are same in all folders then create one and copy folder multiple times

Cheers

@Krithi1,

Try this approach.

  1. Put your folders to be created path in a enumerable type like list or array.
  2. Use Parallel For Each activity.
  3. Inside it use create folder activity
  4. Repeat step 1 to 3 for files creation as well.

This should reduce your run time by atleast halftime.

Thanks,
Ashok :slightly_smiling_face:

any other solutions?

The requirement is not fully clear, I am afraid. Can the files and folders be named randomly?

No, they are fixed folder names and file names, but decide in diff diff folder structures

Main Folder > Sub Folder 1
Sub Folder 2 > Child Folder 1
Child folder 2
Child folder 3
Sub Folder 3 > Child folder 1 > Grand child folder 1

and so on.

This would be very close to what you are looking for; tweak it to your requirement:

Not String.IsNullOrWhiteSpace(currRow(intColIndex).ToString) OrElse intColIndex > 4

Path.Join(strFolderPath, currRow(intColIndex).ToString)

Not String.IsNullOrWhiteSpace(currRow(intFileIndex).ToString)

Footnote:
If the path parameters are not known or can be anything under the sun (as it happens when processing external documents and creating dynamic paths based on content in the file), it may be a better choice to use

Path.Combine

instead of

Path.Join

Also, it id advisable to always clean the path and filename when dealing with unpredictable input using

Path.GetInvalidFileNameChars()

and

Path.GetInvalidPathChars()

These 2 functions return a Char Array, so use LINQ to clean your input.