web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Save file into differe...
Power Automate
Answered

Save file into different folders based on filename

(0) ShareShare
ReportReport
Posted on by 19

Hi all,

New to Power Automate. I have looked at the many questions to this on here, and none of the solutions seem to work for me. All I'm trying to achieve is to save files (.csv) in a SharePoint folder to different folders within SharePoint based on their filename. See the attached images for the flow and values below.

 

Errors:

The variable 'FolderPaths' of type 'Array' cannot be initialized or updated with value of type 'Object'. The variable 'FolderPaths' only supports values of types 'Array'.

 

BadRequest. The variable 'FolderPaths' of type 'Array' cannot be initialized or updated with value of type 'Object'. The variable 'FolderPaths' only supports values of types 'Array'.

 

ActionConditionFailed. The execution of template action 'Filter_array' is skipped: the 'runAfter' condition for action 'Initialize_variable' is not satisfied. Expected status values 'Succeeded' and actual value 'Failed'.

 

Here is what I have put into the different actions.

Initialize variable

{
"AKL": "/attachments/AKL",
"BSS": "/attachments/BSS",
"PCA": "/attachments/PCA"
}

 

Filter array

endsWith(triggerBody()?['{Name}'], '.csv')

 

Apply to each

outputs('Filter_array')?['body']

 

Compose

last(split(item()?['{Path}'], '/'))

 

Compose

variables('FolderPaths')[outputs('Compose')?['result']]

 

Open to any other ways of doing that will be easier.

 

flowpg2.PNG
flowpg1.PNG
Categories:
  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @extratallems 

    This is a format of JSON object which you have shared 

    {
    "AKL": "/attachments/AKL",
    "BSS": "/attachments/BSS",
    "PCA": "/attachments/PCA"
    }

     

    to make it as array , try like this 

     

    [
    "AKL": "/attachments/AKL",
    "BSS": "/attachments/BSS",
    "PCA": "/attachments/PCA"
    ]

     

     

    Also i don't understand why you have used filter array. 

     

    May be you can give me an overview of what you are trying to acheive so that i can help in designing flow ?

     

  • extratallems Profile Picture
    19 on at

    Thank you for your prompt response. I got this solution from YouTube. In short, I'm creating a flow that picks up attachments from a shared mailbox and stores them in a SharePoint site. Once the files are in a folder called attachments, I then want to move each file to the correct folder based on the name of the file and delete it from the attachment folder.

  • Verified answer
    extratallems Profile Picture
    19 on at

    Issue resolved. Used a condition to check attachments name, then a create SharePoint file. Works well.

  • birdlives Profile Picture
    11 on at

    Hi! New in PA as well.

    Could you share that condition, and where you put it in the flow? (without share sensitive data, of course).

    Thanks in advance!

  • extratallems Profile Picture
    19 on at

    Sure, check this video that does a better job than I would explaining. https://youtu.be/_jh7snqA4e4

    Let me know if you still need further assistance.

  • birdlives Profile Picture
    11 on at

    Thanks, @extratallems , as a beginner this helps me a lot.

    I've tried to do it as explained in the video but it finally doesn't seem to work for my goal, because I'd need to identify the attachments by a part of their names, not the complete ones (each day, date is included at the end of attachment date). If only the field marked in yellow would offer also "contains" and not only "equal"...:

    birdlives_0-1685456476205.png

     

    Here you can see what my execution returns with "equal" option:

    birdlives_1-1685456540439.png

     

    Thanks in advance again!

     

  • birdlives Profile Picture
    11 on at

    Correction: "(each day, date is included at the end of attachment NAME)", not date.

  • MWibisono Profile Picture
    75 on at

    Full flow?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 445

#2
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 300

Last 30 days Overall leaderboard