web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Split first 6 characte...
Power Automate
Answered

Split first 6 characters of filename then delete the rest Power Automate Desktop

(0) ShareShare
ReportReport
Posted on by 36

Hey All,

I am new to Power Automate Desktop. I have tried searching the forums for a similar issue to the one I am trying to solve, I have also tried google and even consulted our new Ai companions we now have access to. Unfortunately I am coming up short of an answer to my issue. I am working on a flow where I would like to ask the user to select a directory > Get files in that folder that have .set as the extension. Then loop through those files and extract / split them by the first 6 characters of each filename. For example if the filename was EURUSD_1_5422 I would like to just get the EURUSD and then save this value to a new list. I have setup a flow that I have attached a screenshot of below and it seems to split the filename at the 6th character but it then continues to split the remaining part of the filename which then causes issues. I hope this somewhat makes sense and someone might be able to help or point me in the right direction.

Thank you in advance for any help. Please see below screenshot of the current flow:

Flow.png
 

I have the same question (0)
  • UshaJyothiKasibhotla Profile Picture
    225 Moderator on at

    File name will be stored in a  variable...

    Split the text by using regular expression...

    Use parse text and give your file name variable as input and wrote the regex pattern 

    Enable toggle regular expressions.

     

    Hope this helps

    Usha 

     

     

     

  • Verified answer
    CU16071609-1 Profile Picture
    6,255 Moderator on at

    @Kingston86 

    You've nearly completed a great job. However, in your split action, please make the following correction: Instead of referencing standard length, specify your delimiter. I assume all your filenames are suffixed with "_". Therefore, I've added that as the delimiter in the action below and add ExtractedsetFiles[0] into your List variable.

    Method1:

    Deenuji_0-1709607279187.png

    Method2:

    Instead of employing the split action, utilize the crop text action to trim your filename before the delimiter. Then, add your cropped filename text to your list variable.

    Deenuji_1-1709607999575.png

     

    Method3 - Regex: (it also works in similar way of method1):

    Deenuji_3-1709608658043.png

     

    Full Flow Details:

    Deenuji_2-1709608217417.png

     

    Code:

    Variables.CreateNewList List=> FileList
    Display.SelectFolder Description: $'''Please select your set file directory''' InitialDirectory: $'''C:\\''' IsTopMost: False SelectedFolder=> SelectedFolder ButtonPressed=> ButtonPressed
    Folder.GetFiles Folder: SelectedFolder FileFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> FileNameList
    LOOP FOREACH CurrentFileItem IN FileNameList
    # #Method1
    Text.SplitText.SplitWithDelimiter Text: CurrentFileItem.Name CustomDelimiter: $'''_''' IsRegEx: False Result=> TextList
    Variables.AddItemToList Item: TextList[0] List: FileList
    # #Method2
    Text.CropText.CropTextBeforeFlag Text: CurrentFileItem.Name ToFlag: $'''_''' IgnoreCase: False CroppedText=> CroppedFileName IsFlagFound=> IsFlagFound
    IF IsFlagFound = $'''True''' THEN
    Variables.AddItemToList Item: CroppedFileName List: FileList
    END
    END

     

    -----------------------------------------------------------------------------------------------------------------------------

    If I've resolved your query, please consider accepting it as the solution and giving it a thumbs up to help others find answers faster.

     

     

  • Kingston86 Profile Picture
    36 on at

    Thank you Usha and Deenuji for taking the time to reply to me. Both solutions I believe would have worked which is great. Deenuji your reply was so detailed and for me as a new user made it amazingly easily to follow and get the result I was looking for. Thank you

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @Kingston86 

    Thank you for considering my response as the solution. Happy Automation!!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 252 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 169

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard