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

File Directory, not full path with filename

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?

2 ACCEPTED SOLUTIONS

Accepted Solutions

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.

View solution in original post

We have shown to valid ways to compute the file's directory, but we have not solved the problem.  How can I fix Flow or my Excel table so I can populate the Source column?  I tried thought if I deleted the column and re-added it in the table, it might do it, but it did not. 

 

I conclude that it can't  be fixed.  I can add a new column to the table and start using that.  I can't name it with the old name.

View solution in original post

27 REPLIES 27
Super User III
Super User III

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



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials
Community Support
Community Support

 

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,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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, 

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...

 

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



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials

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.

View solution in original post

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.

I may have it:

 

replace(triggerBody()?['Path'],triggerBody()?['Name'],'')

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

Could you please post your flow screenshot?
Thanks


Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials

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

Hi
Thanks for your quick reply. I want to see the full flow screenshot starting from trigger to end.
Thanks


Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials

flow-screen-source-3.jpg

Hi @akharns 

 

Thanks for the screenshot. 

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

Could you please tell me where you using the expression? Which flow step action and property? I can't see in your screenshot.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials

See the above (1st) screen print.  In "Add A Row Into Event Log", for the "Sources" field, I entered the expression in the Expression builder shown on the right.

Hi,

 

Thanks for the reply. So what you expect in the source field? Lots of questions here. Hopefully we will get there 🙂

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials

I was wanting the source field in the Event Log to have the directory of the created file. My solution was to use the path value, replacing the filename with '', such as replace(triggerBody()?['Path'],triggerBody()?['Name'],''). When I type this in under "Expression" and press OK, it seems to work fine, but then it flashes it into the source field and then clears the field.

Hi @akharns 

 

Could you please tell me which flow action you getting these properties. The below image is from your screenshot.

When I added list files in folder flow step I can't see those properties. Then again I having some issues with my Gateway so that I can't fully test my flow right now. 

 

prop1.png

 

Thanks

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials

List of Files Path and List of Files Name

Hi @akharns 

 

I was asking which flow action step you are getting these properties from?

 

See below these are my properties under List files in folder. As you can see when I filter by text as 'list' no properties are displayed under. You must have a different flow action step here?

 

prop2.png

 

Thanks

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (23,547)