cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Goodmountain
Frequent Visitor

Moving files which appear in certain OneDrive-Folders depending which name they have

Hi,

 

in my work I use a rocketbook, which sends pdf-files to one certain folder in my onedrive. These pdf-files have different filenames, depending on the headline I gave them in my book. It is a matter of order not to give too many different headlines, and I want flow to move (or copy, if it is a difference) the files to different subfolders.

Most Helpful would be to just analyze a part of the filename (for example until a certain letter appears): "Filename$$.pdf" for example could use just the part from first letter to $$ as a destination folder.

A little less helpful, but practicable would be to use the complete filename, but then I would add a timestamp to the filename when moving/copying.

1. The trigger is "When a file is created" in my opinion.

2. Next step is "Create file" in a different folder.

3. Last step is "Delete file" in the triggered folder.

 

But how can I use a part of the filename in the 2. step for changing the target folder?

 

Thanks in advance,

 

C.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Goodmountain
Frequent Visitor

Re: Moving files which appear in certain OneDrive-Folders depending which name they have

Hello everybody,

 

I just figured it out, but in a different way:

 

rock2one 01.jpg

 

replace(variables('Dateiname'), '.pdf', ''

 

rock2one 02.jpg

 

 

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

I store the name of  the file in a variable and change the output by removing the '.pdf', adding the current date and '.pdf'.

This works Robot Happy

 

If there are any questions, feel free to ask.

 

Greetz, Goodmountain

View solution in original post

4 REPLIES 4
Community Support
Community Support

Re: Moving files which appear in certain OneDrive-Folders depending which name they have

Hi @Goodmountain ,

 

You could try the following method to configure Flow.

  • Use Split() function to extract the file name half.
  • Then manually configure the folder path and create the file.

Expression reference:

first(split(triggerBody()?['DisplayName'],'$$'))

Image reference:

102.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.
Goodmountain
Frequent Visitor

Re: Moving files which appear in certain OneDrive-Folders depending which name they have

Hi Barry,

 

that'a weird, I receive an error that the first paramter value is not a string...

 

rock2one.jpgI used your expression reference as it is, but it didn't looked like I had to change anything in it.

Why is this expression of type 'Null', the reason can't be the format pdf, am I right?

 

Best regards,

 

Goodmountain

Goodmountain
Frequent Visitor

Re: Moving files which appear in certain OneDrive-Folders depending which name they have

Ok, the mist is getting lighter Robot wink

 

I tried your example, but with a completely different content of "Compose".

It was replaced with 

min(1, 5, 4, 3)

and gave back - surprise - "1".

So, the expression

first(split(triggerBody()?['DisplayName'],'$$'))

gives back 'Null' and the flow stops...

The triggerBody() is completely unknown to me, but it doesn't seem to give back a part of the filename... in fact it sees not to give back anything at all.

The manual (https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#t... doesn't help me with the expression 'DisplayName' or any other possibilities. Is there a more detailed manual, which I did not find yet? Robot Sad

 

Thanks in advance,

 

Goodmountain

Goodmountain
Frequent Visitor

Re: Moving files which appear in certain OneDrive-Folders depending which name they have

Hello everybody,

 

I just figured it out, but in a different way:

 

rock2one 01.jpg

 

replace(variables('Dateiname'), '.pdf', ''

 

rock2one 02.jpg

 

 

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

I store the name of  the file in a variable and change the output by removing the '.pdf', adding the current date and '.pdf'.

This works Robot Happy

 

If there are any questions, feel free to ask.

 

Greetz, Goodmountain

View solution in original post

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

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 (6,584)