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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / NEWBIE - MOVE FILES BA...
Power Automate
Unanswered

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

I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 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,129 Super User 2025 Season 2 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,129 Super User 2025 Season 2 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

  • Verified answer
    Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 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,129 Super User 2025 Season 2 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard