cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kell
New Member

Copy a file from a SharePoint document library to another based on file name that contains a numerical range.

Hello, 

 

I am trying to create a flow that will copy a file from one SharePoint Library to another based on the file name. 

 

The file name will always be similar to this format: XXXX-XXXX-####_R1.pdf. What I would like to copy by is the #### part of the name that could be a range similar to 0001 to 0999. 

 

If someone could point me in the right direction that would be greatly appreciated. 

2 ACCEPTED SOLUTIONS

Accepted Solutions

Hi @Amanthaper ,

 

1) There wont always be a underscore after the ####. It will always have a - before ####. 

2) The #### range will always be a four digit number, basically from 0001 to 8000 but the ranges will be broken out as 1000 - 1999, 2000 - 2999. 

3) If there is a underscore in the name it will always be _R# 

 

Thank you. 

 

View solution in original post

Amanthaper
Responsive Resident
Responsive Resident

@Kell 

Please see this updated expression based on your response.

Substring(replace(variables('hackname'),' ',''),add(lastIndexOf(replace(variables('hackname'),' ',''),'-'),1),4)

You first mentioned first that the name could be XXXX-XXXX-####_R1 or 1000 - 1999, 2000 - 2999 which are quite different.

The expression above works with any of those patterns. Give it a shot.

 

Cheers,

Aman

------------------------------------------------------------------------------------------------------
If my post helps you with your problem or answers your question, please mark it Solved or Answered. This helps anyone with similar challenges. If you like my response, please give it a Thumbs Up.
------------------------------------------------------------------------------------------------------

View solution in original post

5 REPLIES 5
Amanthaper
Responsive Resident
Responsive Resident

Hi @Kell 3 questions,

1) Is there always an underscore after the #### and a - before it? Is this the only underscore in the file name?

2) Will #### range always be 4 digits. You mentioned 0001 to 0999. Is this right?

3)  Are there always 2 letters after the underscore (R1)?

 

Thanks,
Aman

 

Hi @Amanthaper ,

 

1) There wont always be a underscore after the ####. It will always have a - before ####. 

2) The #### range will always be a four digit number, basically from 0001 to 8000 but the ranges will be broken out as 1000 - 1999, 2000 - 2999. 

3) If there is a underscore in the name it will always be _R# 

 

Thank you. 

 

@Kell 

Using your convention in an example, I used the following function to get the characters you mentioned:

Substring(variables('hackname'),sub(lastIndexOf(variables('hackname'),'_'),4),4)

Replace variables('hackname') with your object reference.

PAUG_stringfun1.png

Cheers,

Aman

------------------------------------------------------------------------------------------------------
If my post helps you with your problem or answers your question, please mark it Solved or Answered. This helps anyone with similar challenges. If you like my response, please give it a Thumbs Up.
------------------------------------------------------------------------------------------------------

@Amanthaper  Thank you!!!!

Amanthaper
Responsive Resident
Responsive Resident

@Kell 

Please see this updated expression based on your response.

Substring(replace(variables('hackname'),' ',''),add(lastIndexOf(replace(variables('hackname'),' ',''),'-'),1),4)

You first mentioned first that the name could be XXXX-XXXX-####_R1 or 1000 - 1999, 2000 - 2999 which are quite different.

The expression above works with any of those patterns. Give it a shot.

 

Cheers,

Aman

------------------------------------------------------------------------------------------------------
If my post helps you with your problem or answers your question, please mark it Solved or Answered. This helps anyone with similar challenges. If you like my response, please give it a Thumbs Up.
------------------------------------------------------------------------------------------------------

Helpful resources

Top Solution Authors
Users online (4,134)