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 / Move files to folder b...
Power Automate
Answered

Move files to folder based on filename

(0) ShareShare
ReportReport
Posted on by 5

Hi,

 

I am trying to move files from a local folder (no cloud) into a set of local folders, depending on the file name, with Power Automate Desktop.

So e.g. filename could be CUS1000_Invoice_1234. That file should be moved into folder "CUS1000", ideally into the subfolder "Invoice" (optional).

I have seen a few solutions with Power Automate (Cloud) using the split function etc. but none for the Desktop version. 

 

I do appreciate any help.

 

Best regards, Tim

I have the same question (0)
  • Verified answer
    Highboy Profile Picture
    1,187 Super User 2024 Season 1 on at

    You can use Split text to create a list

    Highboy_0-1634218203972.png

     

    This will produce a list with three elements, that you can use to move the files to the folder you want.

    Highboy_1-1634218245625.png

    Highboy_2-1634218858665.png

     

    You can paste the text below into PAD to see the example

    Folder.GetFiles Folder: $'''c:\\test''' FileFilter: $'''*''' 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 CurrentFile IN Files
    Text.SplitWithDelimiter Text: CurrentFile.NameWithoutExtension CustomDelimiter: $'''_''' IsRegEx: False Result=> TextList
    File.Move Files: CurrentFile Destination: $'''c:\\Movedfiles\\%TextList[0]%\\%TextList[1]%''' IfFileExists: File.IfExists.DoNothing MovedFiles=> MovedFiles
    END

  • TimMuenz Profile Picture
    5 on at

    Thanks, that looks promising. Do you know how to apply this to each of the retrieved files i get from the folder?

  • Highboy Profile Picture
    1,187 Super User 2024 Season 1 on at

    It will do it for all files in the folder, unless you specify a "File filter"

    The Get files, will get all files in a specified folder

    The "for each" loop will travel through the list of files.

  • Jayaram_B Profile Picture
    2 on at

    If you provide how you did that approach on cloud, that will be useful for me.

    Thanks in advance

     

    Regards,

    Jayaram B

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 784

#2
Valantis Profile Picture

Valantis 581

#3
Haque Profile Picture

Haque 545

Last 30 days Overall leaderboard