Extract folder Based on partial name

I have a scenario in which I need to Look for the multiple Folder .Inside a main folder based on ID available with me.

As you can see in the below Screenshot .Listed are multiple folder and I have Values like {“345708”,“340138”,“338115”,“353220”} using these values I need to find Folder and Zip that Folder and move it to other location.
Can any one suggest me the steps to perform this .

@shashank_dullu

use for each for the value which are present in the array

inside the array use assign activity and pass the below expression

System.io.Directory.GetFiles(“Main Folder Path”,CurrentItem+“*”).first

below that use what ever you want to do

Hi @shashank_dullu

You can use For Each Folder in A Folder For iterating through the folders.
Inside that use if condition to check the Folder name contains your string if it matches then you Zip That file using Compress/Zip Files

Hope this Helps :slight_smile:

Hi @shashank_dullu

Get Folder Names:
Assign activity: folderNames = Directory.GetDirectories(“Path\to\main\folder”)

Filter Folders Based on IDs:
For Each activity (TypeArgument: String, Values: folderNames)
If YourListOfIDs.Contains(Path.GetFileName(folderName))
Then
// Process the folder
Else
//

Zip Folders:
Invoke Method activity:
TargetObject: System.IO.Compression.ZipFile
MethodName: CreateFromDirectory
Parameters:
in_directoryPath: folderPath
in_destinationArchiveFileName: “Path\to\output\folder\output.zip”

Move Zipped Files:
Move File activity:
Source: “Path\to\output\folder\output.zip”
Destination: “Path\to\destination\folder\output.zip”

Hi @shashank_dullu ,
you can use ‘GetDirectories’ to get all the subfolders inside it as an array.
then foreach folder in array folder
can find folder name ‘contains’ then zip it
regards,

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