I’m having a requirement where I should sort files based on name, for example:
If the file name follows the format of “CustomerName_Report_DDMMYYYY.xlsx/.pdf ” sort this into a folder based on the year (YYYY )
If it doesn’t follow the above format I should create a new folder with today’s date (format MMDDYYYY ) and move them there.
I know I should be using a for each loop, but am unsure how to filter based on name and create new folders.
Thanks for answering, but how can I filter based on name for example I want all folders that start with CustomerName - DDMMYYYY to be moved to a new folder (that’ll be created within the automation) based on the Year.
and if the folder doesn’t follow the following naming format then it should be moved to a folder based on today’s date
Could you maybe provide us with some visuals (Screenshots) of the files with that particular format and where will the each file be placed after the operation, this is asked just to avoid small confusions that would arise when understanding your initial post.
Also does this mean, you would want to move the file to a Folder which has that respective year ?
Maybe something in the below manner ? But it does open some other questions as well.
In that case, Maybe the below was the required Skeleton/workflow :
In the If Activity the condition used is using the Regex.IsMatch method to check if there is a file matching the format specified. If there is a Match then we capture the Year value only from it and created a Folder in it’s name and place the file in that folder.
If the File name doesn’t match we create a Folder with Today’s Date in the format ddMMyyy and place the file in it.
I figured out to fix some errors, now the workflow is executing well but the following condition:
Is not working as intended as no folders are matching this condition. (File name example: Chandler Bing_Report_25072019) this file should match the written condition but it’s not.
Definitely the customer name is dynamic thus it can’t be known, but the file name will always be something like that “FName LName_Report_25072019”.
Will the mentioned condition in the image work in that case?