cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ML147243
Helper I
Helper I

Set Destination folder based on original file path

I've made an archive library that is the same template as the original library. 

 

I have been able to set up a file move when the archive column is checked.

I would like to know if it is possible to have the destination folder change based on the file's original folder path. 

 
 

2021-11-30_12-45-44.jpg

 Thank you,

6 REPLIES 6
v-bofeng-msft
Community Support
Community Support

Hi @ML147243 :

I've made a test for your reference:

1\My library

vbofengmsft_2-1638413651876.png

vbofengmsft_3-1638413661991.png

  

 

vbofengmsft_1-1638413213544.png

My Flow:

vbofengmsft_6-1638413748973.png

Expression:

take(
  replace(items('Apply_to_each')?['{Path}'],'administrative','archive_administrative'),
  sub(
    length(
        replace(items('Apply_to_each')?['{Path}'],
        'administrative',
        'archive_administrative')
    ),
    1
  )
)

 

The Result

vbofengmsft_4-1638413707439.png

vbofengmsft_5-1638413718322.png

Best Regards,

Bof

 

 

 

ML147243
Helper I
Helper I

Thank you for replying @v-bofeng-msft . When I follow your example I get this error. 

 

Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The repetition action(s) 'Apply_to_each' referenced by 'inputs' in action 'Move_file' are not defined in the template.'.'.

Hi @ML147243 :

Could you please show me your flow and expression?

Best Regards,
Bof

ML147243
Helper I
Helper I

@v-bofeng-msft 

It is set to run daily, 

2021-12-08_12-30-21.jpg the take expression is pasted from what you supplied before: 

take (
  replace(items('Apply_to_each')?['{Path}'],'administrative','archive_administrative'),
  sub(
    length(
        replace(items('Apply_to_each')?['{Path}'],
        'administrative',
        'archive_administrative')
    ),
    1
  )
)

Hi @ML147243 :

The "Apply to each" action's name is "Apply_to_each_3" instead of "Apply_to_each"

vbofengmsft_0-1639016104516.png

 

take(
  replace(items('Apply_to_each_3')?['{Path}'],'administrative','archive_administrative'),
  sub(
    length(
        replace(items('Apply_to_each_3')?['{Path}'],
        'administrative',
        'archive_administrative')
    ),
    1
  )
)

 Best Regards,

Bof

ML147243
Helper I
Helper I

Hello,

 

I made the changes as you suggested but it keeps changing the destination folder to the original file path. Is it because they are in different libraries?

Helpful resources

Announcements
Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

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