How to create a folder for each file and move the files into that folder?

For Example: i want to create a folder for each file in a folder and move the files in created folder

1 Like

There is a activity called “create folder” you can use that within a loop.

and also i need to move the files into that folder

There is two ways for you to achieve this:

  1. If you are using newer versions of studio, you can use “For each file in folder” activity, like the following:

folderPath variable should be the path for your “New Folder”

Inside create folder and Move file to:

Path.Combine(folderPath, Split(CurrentFile.Name, ".")(0))

If you are using older versions:

Use the following in create folder and Move file to:

Path.Combine(folderPath, Split(Path.GetFileName(item), ".")(0))

can u send me the code in create folder activity?

In the first print:

Path.Combine(folderPath, Split(CurrentFile.Name, ".")(0))

In the second:

Path.Combine(folderPath, Split(Path.GetFileName(item), ".")(0))

thanks for the help bro

1 Like

No problems! Happy to help!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.