Selectfolder12

Hey,how to select a folder using select folder, then loop throughout the folder, then using split activity to findout their extension and then to sort them to a new folder according to their extension
Example.: If my folder consists of 3 pdf , 2 jpg , i want the final output to be 3 pdf files should be under a new folder named pdf and likewise others. Using split activity must

@Aadhithyan_Suresh - Is this any academy practice?? Why Split activity is must?

Can Do!

I’ve attached a nifty workflow to help get you started.
Loop Through a Specified Directory - Return File Path and Extension.xaml (6.2 KB)

There are a few elements here - I took care of the items in bold for you. I bet you can figure out the rest!

Please let us know if you need more help!

  1. Ask a user to select a directory
  2. Use the Directory.GetFiles Command to get every file in the specified directory
  3. Loop through every file in the specified directory
  4. Use the Path.GetExtension Command to get the extension for each file
  5. Create a folder using the extension name
  6. Move the file to that folder

Get a list of files in a selected directory - Directory.GetFiles(FilePath)

Get the extension for a file - Path.GetExtension(filePath)

1 Like

No, I’m just practicing,

Can we use split activity to split file names and get extension, like split using “.” and finding extension

Hello,

Instead of using split method, it’s easy if you use syntax
Path.GetExtension(filepath)

Assign this to variable inside the loop

1 Like

I sent this in a DM but I’m throwing it in here in case it can help someone else!

Find Extension - Split Command and Last Command.xaml (5.1 KB)

Assuming 1 "."

String.Split("."c)(1).ToString

Assuming 1 or more "."

String.Split("."c).Last.ToString