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 / NEWBIE - MOVE FILES BA...
Power Automate
Answered

NEWBIE - MOVE FILES BASED ON FILE NAME

(0) ShareShare
ReportReport
Posted on by 18

Hello and thank you to who will help me.

I am totally new to the world of automatization since my background is totally different.

Rookie question: I have a folder with a certain amount of files inside.

The naming of the files is structured as follows:

 

EMV-41-MOD-EMV-GHE-V09.ifc.rvt

EMV-41-MOD-EMV-GHE-V10.ifc.rvt

EMV-41-MOD-EMV-GHE-V11.ifc.rvt

 

EMV-41-MOD-EMV-GLU-V12.ifc.rvt

EMV-41-MOD-EMV-GLU-V13.ifc.rvt

EMV-41-MOD-EMV-GLU-V14.ifc.rvt

 

etc. You can easily see the path.

 

Inside each group of files (being all files starting with EMV-41-MOD-EMV-GHE one group, and all files starting with EMV-41-MOD-EMV-GLU another group, and so on) I want to move the files with the lower V## value to a specific folder.

How can I do it? So far I have only been able to move all files with .ifc.rvt extension.

Thank you

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @fedealbo 

     

    Could you please elaborate what you meant by lower V## value ?

     

    Thanks & Regards,

    Nived N

  • fedealbo Profile Picture
    18 on at

    Yes, sure. Each file has a version number, which I have highlighted in bold. This number increases as the project develops. I want, within the same group of files, to move the files with a smaller version number to a specific folder.

     

    Example:

     

    EMV-41-MOD-EMV-GHE-V09.ifc.rvt

    EMV-41-MOD-EMV-GHE-V10.ifc.rvt

    EMV-41-MOD-EMV-GHE-V11.ifc.rvt

     

    EMV-41-MOD-EMV-GLU-V12.ifc.rvt

    EMV-41-MOD-EMV-GLU-V13.ifc.rvt

    EMV-41-MOD-EMV-GLU-V14.ifc.rvt

     

    Out of this list of files, I want to keep where they are the files in black, and move to a specific folder the files in orange.

     

    Thanks

     

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Ok got it

     

    One more question

     

    Does files are already grouped before the process is started ?

  • fedealbo Profile Picture
    18 on at

    what do you mean? all files are in the same folder before the process is started

    thank you for your help

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Also one more thing,

     

    Does there would be always two groups of files there ?

  • fedealbo Profile Picture
    18 on at

    no, groups are more than two and vary in number

    thank you

  • fedealbo Profile Picture
    18 on at

    this is how far I got but it is not working

    Capture.JPG
  • Verified answer
    Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @fedealbo 

     

    Kindly copy the below code in power automate desktop

     

     

    SET Input_folder TO $'''%''%'''
    SET Output_folder TO $'''%''%'''
    Variables.CreateNewList List=> Pattern_List
    Folder.GetFiles Folder: Input_folder FileFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> Files2
    LOOP FOREACH file1 IN Files2
    Text.Replace Text: file1.NameWithoutExtension TextToFind: $'''V\\d+.*''' IsRegEx: True IgnoreCase: False ReplaceWith: $'''%''%''' ActivateEscapeSequences: True Result=> replaced
    Variables.AddItemToList Item: replaced List: Pattern_List
    END
    Variables.RemoveDuplicateItemsFromList List: Pattern_List IgnoreCase: False
    LOOP FOREACH pattern IN Pattern_List
    Variables.CreateNewList List=> Version_List
    Folder.GetFiles Folder: Input_folder FileFilter: $'''%pattern%*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> Files
    LOOP FOREACH file IN Files
    Text.SplitText.SplitWithDelimiter Text: file.NameWithoutExtension CustomDelimiter: $'''-''' IsRegEx: False Result=> text_list
    Text.Replace Text: text_list[text_list.Count - 1] TextToFind: $'''V''' IsRegEx: False IgnoreCase: False ReplaceWith: $'''%''%''' ActivateEscapeSequences: False Result=> version_number
    Text.ToNumber Text: version_number.Trimmed Number=> version_no
    Variables.AddItemToList Item: version_no List: Version_List
    END
    Variables.SortList.SortList List: Version_List
    Variables.RemoveItemFromList.RemoveItemFromListByIndex ItemIndex: Version_List.Count - 1 List: Version_List
    LOOP FOREACH index IN Version_List
    Text.FromNumber Number: index DecimalPlaces: 0 UseThousandsSeparator: False FormattedNumber=> version_text
    Text.Pad Text: version_text PadPosition: Text.PadPosition.Left PaddingText: 0 TotalLength: 2 PaddedText=> PaddedText2
    File.Move Files: $'''C:\\Users\\Nived\\Desktop\\Temp\\Data\\%pattern%V%PaddedText2%.txt''' Destination: Output_folder IfFileExists: File.IfExists.Overwrite MovedFiles=> MovedFiles
    END
    END

     

     

     

     

    Output got 

     

    Input folder

     

    Nived_Nambiar_0-1678804524502.png

     

     

     

    output folder 

    Nived_Nambiar_1-1678804541481.png

     

     

     

    Note: I have used text file here, so while using the code , change the extension accordingly.

     

    Thanks & Regards,

    Nived N

     

  • fedealbo Profile Picture
    18 on at

    thank you so much for your answer, but I can't make it work

    fedealbo_0-1678805850464.png

    fedealbo_1-1678805872913.png

    what am I doing wrong?

     

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Could you show what error you are getting ?

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

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 423

#2
11manish Profile Picture

11manish 308 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 177

Last 30 days Overall leaderboard