Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Adding first ten characters of a file to folder path

Hello there,


I think this one is easy for professionals Smiley Happy


In my company, we get daily mails with attachments showing the production results of the former evening. There are two shifts in production, so we get one e-mail at 6pm of the first shift and the second e-mail at 2am of the following day from the second shift.

My flow saves the attachements in folders on a sharepoint, which have the naming yyyy-mm-dd.
I solved it whith the 

convertTimeZone(utcnow(),'UTC','W. Europe Standard Time','yyyy-MM-dd')

for the first e-mail (this function in folderpath creates automatically a folder with the current date).

While the second mail arrives on the next day, I use 

FormatDateTime(AddDays(convertTimeZone(utcnow(),'UTC','W. Europe Standard Time','yyyy-MM-dd'), -1), 'yyyy-MM-dd')

for the attachements to be placed in the same folder as the attachement from the first function.


These ones work fine, but there is a third e-mail, which normally is send in the morning at 9am - no problem when I use the first function, but on monday, there is a special case: I get a mail from fridays production as well as from sundays production. My first function copies both mails in the same folder, which is no problem but it is not correct and I do not like it... Smiley Frustrated


I am looking for a workaround to copy the friday mail attachement in the production day folder of friday, and the sunday mail attachement in the production day folder of sunday.

Luckily, the filenames start with the same characters as my folders do: yyyy-mm-dd_filename.xls. So I think, the easist way is to extract the first ten characters from the filename and copy the attachement in a folder on the sharepoint using these characters for the folderpath.


But unluckily, I do not find a function which cuts parts of the filename off. I tried "substring" but was not able to declare the filename as the textstring of the function:

substring(text: string, startIndex: integer, length: integer)

Can anybody help, either with a function to cut off the substring or with a completely different workaround?


Thanks in advance,



Super User
Super User


Inside of the Apply to each loop where you are looping through the attachments, you can use the following expression:


While the Name is not available to you via Dynamic properties, you can still use it by referencing it in this way.
If this addresses your issue, please mark you post as Solved.
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.




I'm sorry, it doesn't work:


When I try to replace the FormatDateTime expression in Folderpath Section with yours



the following error message is shown: 





In fact, I do not even know what that means, normally I have an idea when facing an error message...


Thanks anyway,



Can you post a screen shot of your Flow please?



If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.






It's a simple one. I tried replacing the formula then got the error message.





Helpful resources

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,943)