cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
akharns
Level 8

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
akharns
Level 8

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

akharns
Level 8

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

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!



Community Support Team
Community Support Team

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.
Sergio_Carol
Level: Powered On

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, 

Super User
Super User

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!



akharns
Level 8

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

akharns
Level 8

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.

akharns
Level 8

Re: File Directory, not full path with filename

I may have it:

 

replace(triggerBody()?['Path'],triggerBody()?['Name'],'')
akharns
Level 8

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.

Super User
Super User

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!



akharns
Level 8

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

Super User
Super User

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!



akharns
Level 8

Re: File Directory, not full path with filename

flow-screen-source-3.jpg

Super User
Super User

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!



akharns
Level 8

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.

Super User
Super User

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!



akharns
Level 8

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.

Super User
Super User

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!



akharns
Level 8

Re: File Directory, not full path with filename

List of Files Path and List of Files Name

Super User
Super User

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!



Helpful resources

Announcements
firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

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