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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / File Directory, not fu...
Power Automate
Unanswered

File Directory, not full path with filename

(0) ShareShare
ReportReport
Posted on by 433

The Path property contains the file name.  I want to store the File Name and the Directory separately.  How can I get just the directory, without the file name?

Categories:
I have the same question (0)
  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @akharns ,

     

    Follow the below steps:

    pa1.png

     

    For the above Compose - FilePath expression is as follows:

    replace(variables('FileNameAndPath'),last(split(variables('FileNameAndPath'),'/')),'')
     
    For the above Compose -Filename expression is as follows:
    replace(variables('FileNameAndPath'),outputs('Compose_-_FilePath'),'')
     
    Test Results:
    pa2.png
     
    If you need any further help please let me know.
     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

     

    Thanks

  • v-bacao-msft Profile Picture
    on at

     

    Hi @akharns ,

     

    Could you share the specific configuration of Flow?

    If the action you are using is List files in folder action, you could consider using the following method to configure Flow.

    Expression reference:

    first(split(outputs('Path'),outputs('FileName')))

    Image reference:

    90.PNG

     

    Best Regards,

  • Sergio_Carol Profile Picture
    20 on at

    Excuse me, 

     

    How can I access to 'List files in folder'?  (i'm trying to do backup copies of local folders to Onedrive)

    Can I read more file's properties (date, size, ...)

     

    Thna you for your answer in advance, 

  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @Sergio_Carol 

     

    Follow this link @yoshihirok solution.

    https://powerusers.microsoft.com/t5/Flow-Cookbook/Copy-a-file-from-Local-file-server-to-OneDrive-for-Business/td-p/51654

     

    You can also get the property using Get File metadata property flow action.

     

    If you need any futher help please let me know.

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

     

    Thanks

  • Verified answer
    akharns Profile Picture
    433 on at

    Thank you, abm.  My level of expertise on building expressions is extremely limited at this time, but I did get this to work:

     

    1. List Files In Folder

    2. Apply To Each

    3. Add A Row Into A Table

       In one of my output fields, I used the following:  replace(items('Apply_to_each')['Path'],items('Apply_to_each')['Name'],'')

     
    Your solution sounds interesting, but I don't yet understand how to write a series of steps for "apply to each".  I do eventually need to learn how to use multiple steps with variables and compose, as you have done.  I don't know if my expression above is as simple as it could be, but at least it works.  If you have suggestions on how to improve it, I'm listening.  I was wishing that Expressions would help me more than it did.  I think it has done better in the past, so I must have done it differently this time.
     
    You gave me the idea of using replace and some syntax for doing that.  Instead of parsing the path, I just stripped off the file name.
  • akharns Profile Picture
    433 on at

    Correction.  It works in my quick demo, but not in my application.  It must have something to do with how I referenced the fields.  

     

    My application' action is When A File Is Created.  All other fields are pushed from "List of Files", but my syntax is incorrect.

  • akharns Profile Picture
    433 on at

    I may have it:

     

    replace(triggerBody()?['Path'],triggerBody()?['Name'],'')
  • akharns Profile Picture
    433 on at

    Nope.  Expression accepts it, but as soon as it is shown in the output area, it disappears.  Something's still wrong.

  • abm abm Profile Picture
    32,865 Most Valuable Professional on at
    Could you please post your flow screenshot?
    Thanks
  • akharns Profile Picture
    433 on at

    I don't know if this is what you want...flow-screen-source-1.jpgflow-screen-source-2.jpg

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard