cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Move All Folders with Names Starting with a b or c including Files

Hi Power Automate

 

Looking to move all folders that start with a for example a , b or c to new SharePoint location. So, process is as follows

 

Department uploads random name.zip file into the upload directory. The extract is easy, but first issue would be zip extract process creates the folder using the randomized zip name scheme this contains directory list of sub folder with files within each of those folders.

 

My current file structure.

 

1. Staff Employment

 

Sub Folders
1. Data
2. Staging
3. Upload

 

So after this point i need to pick the sub folders folders with the files within the the random zip folder. But i need to only move folders that start with aaa , xxx for example.

 

Any one that can assist with this?

 

Regards Jordan

19 REPLIES 19
annajhaveri
Most Valuable Professional
Most Valuable Professional

@Hom3World  the random zip folder, is it getting created at specific location always? Do you want to move the random zip folder as soon as it is created, or do you want the flow to run at specific schedule like daily or weekly and then scan for random zip folders and move the folders?

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Hi Anna

 

The random zip file name will be export from a website by our HR team and they will drop it into the upload directory. So, script will start the extract upon zip being added to the "Upload" folder.

 

Regards Jordan

 

 

@Hom3World , you can create the flow as follow:

 

1. Use "When a file is created (properties only)" trigger for the flow, this will also trigger when folder is created. Select the SharePoint Site, Document Library and Folder (where the zip folders will uploaded)

annajhaveri_0-1611764847325.png

 

2. Now you may want to add Delay action here, as it will take few seconds/mins to subfolders to get created. Add delay action with delay of 1-2 mins.

 

3. Now check if the new item that is added is folder, if file is added we dont want to do anything, so add Condition action, and configure it as below

annajhaveri_1-1611765047365.png

4. Under the Yes branch of condition add Move Folder action, you will add this action 3 times, as you have 3 sub folders,  Data, Staging and Upload, configure each move action as below, the only thing that will change between these actions is Folder to Move path, and destination folder only if you want these 3 folders to go to different locations.

annajhaveri_3-1611765331837.png

 

 

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Hi @annajhaveri 

 

See below, dont think pervious item works as below  

 

Zip with random name is export by HR and added to “Upload”

 

  • Currently I am extracting zip to “Staging” then deleting the zip file ready for the next upload.

Randomized Zip File Name

Folders Within Zip

Files Within Folders

Random.zip

Newusers

Files

 

Newusers2

Files

 

Newemployee

Files

 

Newempoyee2

Files

 

newsite

Files

 

workload

Files

 

shifts

Files

 

timesheets

Files

 

Timesheets2

 

 

Lots of other folders

 

 

After Extraction – the file structure within Staging is more a less like below.

Folder with random name

Sub Folders

Files Within Folders

Random

Newusers

Files

 

Newusers2

Files

 

Newemployee

Files

 

Newemployee2

Files

 

newsite

Files

 

workload

Files

 

shifts

Files

 

timesheets

Files

 

Timesheets2

Files

 

Lots of other folders

 

 

Final location “Data” should only have specific folders with

 

Logic thinking

 

If folder "Staging" contains or starts with Newusers or Newemployee or timesheets move to “Data”

 

Don’t wish to keep the “random” folder only want the sub folders within in the match parameters. Once move is complete delete all remaining items read for next run.

 

Imagined Final status 

Root

Sub Folders

Files Within Folders

Data

Newusers

Files

 

Newusers2

Files

 

Newemployee

Files

 

Newemployee2

Files

 

timesheets

Files

 

Timesheets1

Files

 

Not sure I gave enough information originally sorry. Any help would be apricated.

 

Regards Jordan

currently got all the below working as expected in my main flow, testing the follow-up parts in a manual flow. Till i can figure out how to get it to work

 

Hom3World_0-1611772385716.png

 

 

@Hom3World  Okay, let me know how it goes and if you have any questions or issues while testing.

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

@Hom3World  can you describe what is not working?

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Hi @annajhaveri 


Hom3World_0-1611850458722.png

Current Extracted Structure

Hom3World_1-1611850485470.png

 

@Hom3World Please configure the flow as follows after the Delete file action:

 

1. To get the folder at location where you file was unzipped, configure the actions as follows (this is done because you may not have New Folder (4) always when you unzip the zip file)

annajhaveri_1-1611921696211.png

2. Then add condition action to determine the list of folders that you have got is one or more. This is done if you have more folders along with New folder (4)

annajhaveri_2-1611921817165.png

Use following expression in condition

length(outputs('List_folder_-_get_zip_folder')?['body'])

3. Now in No Branch of condition add following actions to get the sub folders of New Folder (4)

annajhaveri_7-1611922153900.png

Here use this following expression

first(body('List_folder_-_get_zip_folder'))['Name']

4. Then add List Folder action and configure it 

annajhaveri_9-1611922191703.png

 

5. Now add Apply to each action and provide Body as input of apply to each (Body from the above List Folder action). Then add condition action to determine which folders you want to copy, the expression i have provided below as well. Then in Yes branch add Move Folder action to Move the required folders to desired location

annajhaveri_11-1611922336267.png

 

Expression for condition action to check the folders you want to move, add more equals conditions as per the folders you want to move, i have created expressions for four folders for example

or(equals(items('Apply_to_each_2')?['Name'],'Newmployee1'),equals(items('Apply_to_each_2')?['Name'],'Newmployee2'),equals(items('Apply_to_each_2')?['Name'],'Newmployee3'),equals(items('Apply_to_each_2')?['Name'],'Newmployee4'))

Now we need to add same set of actions under Yes branch of Condition 3 action (the same actions we added to No Branch of Condition 3 action) the only difference is add Apply to each action and provide body (from List Folder - Get Zip folder action) as input to apply to each and then add same actions which we added in the No branch..

I know its lot of instructions, if you feel confused let me know. 

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Also one more thing add below trigger condition to your trigger of the flow from settings, so that your flow doesnt trigger for every subfolder created when the zip file is extracted in SharePoint

@endsWith(triggerBody()?['{FilenameWithExtension}'], '.zip')

annajhaveri_0-1611923133841.png

 

 

This way the flow will only trigger when zip file is added to the folder.

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

This is awesome, no longer need that staging folder now.

 

Thanks.

@annajhaveri 

 

 

or(equals(items('Apply_to_each_2')?['Name'],'Newmployee1'),equals(items('Apply_to_each_2')?['Name'],'Newmployee2'),equals(items('Apply_to_each_2')?['Name'],'Newmployee3'),equals(items('Apply_to_each_2')?['Name'],'Newmployee4'))

 

 

How does this work if i want to match contains ? If name contains xxx or yyy?

 

As the data will actual have 100s if not thousands to employees 

folder names would only start with 

Newemployee
Newuser


ie


Newemployee_Staff member name
Newuser_Staff member name


Regards Jordan

@Hom3World to check contains, just replace the equals with contains as shown below

or(contains(items('Apply_to_each_2')?['Name'],'Newmployee1'),contains(items('Apply_to_each_2')?['Name'],'Newmployee2'),contains(items('Apply_to_each_2')?['Name'],'Newmployee3'),contains(items('Apply_to_each_2')?['Name'],'Newmployee4'))
Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Hi @annajhaveri 

 

Getting an error saving?

 

Get folder only available e under the when item created is this the issue

 

Hom3World_0-1612183992348.png

Correct to include a valid reference to 'List_folder_-_get_zip_folder' for the input parameter(s) of action 'Get_folder_metadata_using_path'.

@Hom3World  It looks correct, not sure why it is erroring out. Try renaming the action to ListFolderGetZipFolder, then use 'ListFolderGetZipFolder' instead of 'List_folder_-_get_zip_folder' in the expression.

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Hi @annajhaveri 

Got that one path working, but if i try upload live data i get a failure on zip extract now? Folder base is around 100 folders. But this size is only around 4 megs currently. Seems a bit odd

  "status"413,
  "message""Archive content is too large. It contains more than '100' files or more than '314572800' bytes in total.\r\nclientRequestId: 85926fed-6bfb-4942-bef5-7b38fd5ae57e\r\nserviceRequestId: 7103a79f-40b9-2000-6f5b-917084cd567d;7103a79f-30bc-2000-6f5b-9b0bb41d0a2e;7103a79f-10bf-2000-6f5b-94ae073e8935",
  "error": {
    "message""Archive content is too large. It contains more than '100' files or more than '314572800' bytes in total."
  },
  "source""sharepointonline-ne.azconn-ne.p.azurewebsites.net"
}

@Hom3World  It looks like extract folder action has limitation on zip file size. Is it possible for the user to extract the zip contents and then upload to SharePoint?

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Hi @annajhaveri 

 

Is there anyway to work around this issue? Folder structure is always going to have more than 100 folders, but data size is currently only around 4-10 megs. Seems crazy this cant be done with such small amounts.

 

Can we maybe move data to azure server then extract. Move back to sharepoint?

 

Also one last question on the yes branch what conditions have been set?

Hom3World_0-1612431498111.png

 

 

Regards Jordan

@Hom3World  you can create you own API to extract zip and upload files to SharePoint folder and then call that API using HTTP action or Custom Connector in Flow. 

 

Below is the explanation of question of condition you have asked for: 

1. List folder - get zip folder - this action gets all the folders where the zip folder is extracted. So there could be other folders at same location or just the zip folder which was extracted. So there could be one or more folders. So that condition is to check whether the action "List folder - get zip folder" returned one folder or more than one. If it returned just one folder (which would be the folder which we got from unzipping the file), then we directly use that folder and do further processing, and if it returned more than one folder, then we need to loop through the resulting folders and find the unzipped folder and do further processing. I hope that makes sense?

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,325)