cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Helper V
Helper V

Re: File Directory, not full path with filename

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

Highlighted
Helper V
Helper V

Re: File Directory, not full path with filename

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
Highlighted
Super User III
Super User III

Re: File Directory, not full path with filename

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
Highlighted
Community Support
Community Support

Re: File Directory, not full path with filename

 

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.
Highlighted
Regular Visitor

Re: File Directory, not full path with filename

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, 

Highlighted
Super User III
Super User III

Re: File Directory, not full path with filename

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
Highlighted
Helper V
Helper V

Re: File Directory, not full path with filename

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

Highlighted
Helper V
Helper V

Re: File Directory, not full path with filename

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.

Highlighted
Helper V
Helper V

Re: File Directory, not full path with filename

I may have it:

 

replace(triggerBody()?['Path'],triggerBody()?['Name'],'')
Highlighted
Helper V
Helper V

Re: File Directory, not full path with filename

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

Highlighted
Super User III
Super User III

Re: File Directory, not full path with filename

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
Highlighted
Helper V
Helper V

Re: File Directory, not full path with filename

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

Highlighted
Super User III
Super User III

Re: File Directory, not full path with filename

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
Highlighted
Helper V
Helper V

Re: File Directory, not full path with filename

flow-screen-source-3.jpg

Highlighted
Super User III
Super User III

Re: File Directory, not full path with filename

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
Highlighted
Helper V
Helper V

Re: File Directory, not full path with filename

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.

Highlighted
Super User III
Super User III

Re: File Directory, not full path with filename

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
Highlighted
Helper V
Helper V

Re: File Directory, not full path with filename

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.

Highlighted
Super User III
Super User III

Re: File Directory, not full path with filename

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
Highlighted
Helper V
Helper V

Re: File Directory, not full path with filename

List of Files Path and List of Files Name

Highlighted
Super User III
Super User III

Re: File Directory, not full path with filename

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (7,526)