cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
james_goodhew Advocate I
Advocate I

Remove everything after 5 digit project number from filename

This is an extension on previous topics, but I can't find anything extracting n digits from filename in a string. 

I need to strip everything off the PDF Name after the 5 digit project number, and use that information as the destination for a Move File action.

 

All project folder names have this structure: PROJECTNAME - 12345

PROJECTNAME has no requirements except less than ~30 characters, and no disallowed characters.

The suffix to end the folder name is SPACE HYPHEN SPACE 5DIGITS (always, this is coded*).

 

What I need to do in Flow is move the PDF of the drawing to its project folder.

The PDF Name is of the format PROJECTNAME - 12345-LAYOUTNAME.pdf

The PDF source location is always the same, and all files created in that location need to be moved.

The destination folder is always Y:\02 Projects\PROJECTNAME - 12345

 

I've initialized variables like:

RequiredLength as Integer, Initial Value 5.

InputText as String, Initial Value 'File Name' (from Dynamic Data)

CharacterList as Array, InitialValue IDONTKNOW


I did find the following from this link, but don't know how to translate the rest into Flow actions:

 

(InputText as text) =>
let
RequiredLength = 5,
Digits = {"0".."9"},
CharacterList = Text.ToList(InputText),
FirstNumber =
List.Accumulate(
CharacterList,
"",
(String,CurrentChar)=>
if Text.Length(String) = RequiredLength then String
else if List.Contains(Digits,CurrentChar) then String & CurrentChar
else ""
) ,
ReturnValue =
if Text.Length(FirstNumber) = RequiredLength then FirstNumber else null
in
ReturnValue

 

 

*until we hit the millennium bug

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Remove everything after 5 digit project number from filename

@james_goodhew - You may want to reference this thread as it has a similar topic to yours. There are expressions listed as well.

 

https://powerusers.microsoft.com/t5/Building-Flows/Split-Extract-names-from-a-delimiter-string-in-Fl...

View solution in original post

2 REPLIES 2

Re: Remove everything after 5 digit project number from filename

@james_goodhew - You may want to reference this thread as it has a similar topic to yours. There are expressions listed as well.

 

https://powerusers.microsoft.com/t5/Building-Flows/Split-Extract-names-from-a-delimiter-string-in-Fl...

View solution in original post

james_goodhew Advocate I
Advocate I

Re: Remove everything after 5 digit project number from filename

@PowerBack19 Thank you, that is a helpful post for any newcomer (which I was until abm helped me see how to use expressions)! My question is about using an integer of n digits as a delimiter, I'll create a new post about that and mark this one as a solution.

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

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
Users online (7,437)