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

Organise sharepoint by file type

Hi all

Having a bit of a nightmare here. Basic flow idea is when a new file is created I want the flow to move it to a specific folder depending on its file type.

I have tried with the condition function but it wouldn’t read the file extension. I then tried actually renaming a file mov.mov and tested the flow to see if it would recognise that it contained the word ‘mov’ and still I got a false result.

Reddit has thrown up a few solutions on how people run this from email attachments but the required using a JSON editor - it must be simpler than that!

Also note that the condition function now doesn’t display advanced editing so I can’t find a way to edit the code there.

Any help would be great!
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Hi!

 

Let's talk about your new challenges:

"I tried swapping this for a condition as shown in my picture and the flow ran through to the end but gave a 'false' result even though the file should have been recognised as true."

The problem seems to be you did not assign the expression to the 'Initialize variable' in the proper way. Please follow these simple steps to add it:

https://flow.microsoft.com/es-es/blog/use-expressions-in-actions/

 

"In the solution provided what would I enter into the 'case equals' section?"

Think you already figured out, right? You need to enter file extension:

Case 1: enter mp4

Case 2: enter mp3

Case 3: enter jpeg

...

Case Default: whatever extension value that does not match with the previous ones

 

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

6 REPLIES 6
Highlighted
Dual Super User III
Dual Super User III

Hi!
I would try the following
-when a new file is created
-get file properties

..so you will get a property called '{FilenameWithExtension}'

My memory is not very reliable and not with my laptop, unable to test, but look a valid approach according to
https://powerusers.microsoft.com/t5/Building-Flows/When-a-file-is-created-properties-only-vs-When-a-...
You can use another trigger also , as explained in the thread
Hope this helps


Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted
Super User II
Super User II

Hello @Chrissimmonds 

A similar solution to the one by @efialttes would be the following:

split.png

 

1) Get file metadata.

2) Initialize a variable to get the file extension using the split function: split(body('Get_file_metadata')?['Name'],'.')[1]

This functions splits the filename by the dot character, and gets the second element, which should be the extension.

3) Use a switch command based on the file extension variable to perform different actions.

 

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
Highlighted
Dual Super User III
Dual Super User III

Thanx, @fchopo for sharing an alternate, so well docummented approach!

 

@Chrissimmonds 

Please give it a shot, if you finally overcome your challenge remember you can even select several replies as as 'Solution', even from different community members!

Flow_AcceptSolution.png

Thanx for making this community great!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted

Thanks to you both @fchopo  and @efialttes ,

 

I feel like I'm getting somewhere now!

I was having a few problems with the first solution - I may revisit and explain exactly what was happening tomorrow AM. Just had a quick go at @fchopo 's solution and feel like i'm almost there.

I can get a successful run all the way down to the switch. 

In the solution provided what would I enter into the 'case equals' section?

 

I tried swapping this for a condition as shown in my picture and the flow ran through to the end but gave a 'false' result even though the file should have been recognised as true.

 

Also is it better to use the 'when a file is created in a folder' than the 'when a file is created (properties only)' function?

 

I appreciate the help, as you can tell I'm very new to this!

 

Screenshot 2020-04-19 at 12.47.46.png

Highlighted

Hi!

 

Let's talk about your new challenges:

"I tried swapping this for a condition as shown in my picture and the flow ran through to the end but gave a 'false' result even though the file should have been recognised as true."

The problem seems to be you did not assign the expression to the 'Initialize variable' in the proper way. Please follow these simple steps to add it:

https://flow.microsoft.com/es-es/blog/use-expressions-in-actions/

 

"In the solution provided what would I enter into the 'case equals' section?"

Think you already figured out, right? You need to enter file extension:

Case 1: enter mp4

Case 2: enter mp3

Case 3: enter jpeg

...

Case Default: whatever extension value that does not match with the previous ones

 

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

Highlighted

hi @Chrissimmonds  this is an example of maeby what you need. See you can add condition as you want by cliking (+). I saw that  @fchopo  gives you this option and complementing with @efialttes  solutions. This is what you need to do.

case.PNG



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

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.

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