Match file name with current month folder name

Hello community!

I have a filenamed-21012024.zip this is my file and daily the filename will be in ddMMyyyy format only.
I want to upload this let say in a month folder-January 2024/ which is like this.
What i want is bot will check the filename for which month is this filename belongs
Example-if it is 012024 then it will upload in january 2024

What logic can i add in my workflow for this?

Hi @Priyesh_Shetty1

Can you try below way

filePath = "21012024.zip"
fileName = Path.GetFileNameWithoutExtension(filePath)
fileDate = DateTime.ParseExact(fileName, "ddMMyyyy", System.Globalization.CultureInfo.InvariantCulture)
folderPath = Path.Combine(fileDate.ToString("MMMM yyyy"), filePath)

fileDate is of DataType System.DateTime. Other variables are of Datatype System.String.

Hope it helps!!
Regards

@mkankatala this file i want to upload in a website actually there are lot month folders so bot will search the month folder according to file name and then it will upload in that folder.

Hi @Priyesh_Shetty1


filePath = "21012024.zip"
fileName = Path.GetFileNameWithoutExtension(filePath)
fileDate = DateTime.ParseExact(fileName, "ddMMyyyy", System.Globalization.CultureInfo.InvariantCulture)
folderName = fileDate.ToString("MMMM yyyy")

→ Use Folder Exists activity to check whether whether January 2024 folder exists in that particular path location. Give the below path. You cange C:\ as per yours. Save that into variable. The output will be a boolean datatype.

Path.Combine("C:\",Now.ToString("MMMM yyyy"))

→ Use If condition to check folder exists. If exists it won’t create a new folder, if not it will create a New folder.


The same condition used in folder Exists has been given in Create folder.

Hope it helps!!
Regards

@mkankatala i want to upload this file in a website in that website only there are folders available to upload the file and there is a search box also to search the folder name…I dont want to upload this file in directory.

Hi @Priyesh_Shetty1 In that case use the same code provided by @mkankatala

  1. use TypeInto Activity → Search Box → FolderName -->Click on Search
  2. Use Element Exists to check for the results returned by Search Criteria
  3. If (MonthExists) which will be boolean value, your upload code goes here.

Above sequence mimics the same behaviour, but you need to update the code as per your use case.

Thanks