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 / Copy file When a file ...
Power Automate
Answered

Copy file When a file is created or modified in subfolders

(0) ShareShare
ReportReport
Posted on by 522

I have a basic flow which is running when a file is created or modified in a subfolder and copy file into another destination folder. What i want to enhance with this flow is to copy file from subfolders and copy file into destination subfolder. I want copy in destination dynamically instead of static. If modified in any one of subfolder, the file should be copied to destination matching to source folder.

 

Source structure:

Abc/01.Abc/02.Abc/File.docx

Test/1.Test/2.Test/3.Test/Demo.ppt

 

I have one to one file structure like source structure in destination, when something is modified or created i want to copy exactly in the same structure.

 

Destination structure:

Abc/01.Abc/02.Abc/copy file here

Test/1.Test/2.Test/3.Test/Demo.ppt

Categories:
I have the same question (0)
  • v-jefferni Profile Picture
    on at

    Hi @Nikhil2 ,

     

    You can Get file content and Create file instead of Copy file. Create file action will automatically create the folder path for a new file if the path does not exist yet.

     

    Could you please share the complete file paths for the two example files? Are Abc and Test two libraries? 

     

    Best regards,

  • Nikhil2 Profile Picture
    522 on at

    @v-jefferni 

    Yes since i am testing this flow the complete file path like below, but I will have 7 parent folders and many nested folders inside 7 folders. I do not want to create flow for each subfolders, I want make dynamically create or copy file in destination based on source folder.

     

    Source structure:

    Abc/01.Abc/02.Abc/File.docx

    Test/1.Test/2.Test/3.Test/Demo.ppt

     

    Destination structure:

    Abc/01.Abc/02.Abc/copy file here

    Test/1.Test/2.Test/3.Test/Demo.ppt

  • v-jefferni Profile Picture
    on at

    Hi @Nikhil2 ,

     

    I still cannot understand your example. 

     

    From 

    Abc/01.Abc/02.Abc/File.docx

    Test/1.Test/2.Test/3.Test/Demo.ppt

     

    To

    Abc/01.Abc/02.Abc/File.docx

    Test/1.Test/2.Test/3.Test/Demo.ppt

     

    But there's no difference at all...

     

    Best regards,

     

  • Nikhil2 Profile Picture
    522 on at

    @v-jefferni I have same the folder structure in source and destination. Destination Parent folder is different.

    Sorry my mistake.

     

    From 

    Abc/01.Abc/02.Abc/File.docx

    Test/1.Test/2.Test/3.Test/Demo.ppt

     

    To

    Abc01/01.Abc/02.Abc/File.docx

    Test01/1.Test/2.Test/3.Test/Demo.ppt

  • Nikhil2 Profile Picture
    522 on at

    @v-jefferni And Files are newly created everyday, the files not constant and sometimes the files are modified.

  • Verified answer
    v-jefferni Profile Picture
    on at

    Hi @Nikhil2 ,

     

    It doesn't matter, new files or modified files will be created in destination folder. If it's new file, create new, if file is modified, file will be covered in destination folder.

     

    Flow:

    vjefferni_5-1713150481170.png

    Compose:

    join(skip(split(trim(triggerOutputs()?['body/{Path}']),'/'),2),'/')

    Compose2:

    split(trim(triggerOutputs()?['body/{Path}']),'/')[1]

    vjefferni_4-1713150302565.png

     

    Source folder and new file created in the folder:

    vjefferni_0-1713149535826.png

     

    Destination folder and file copied in the folder:

    vjefferni_3-1713150268970.png

     

    Best regards,

  • Nikhil2 Profile Picture
    522 on at

    @v-jefferni It works as expected but instead of creating folder01 can we just map to the desired folder ?

    Because i have already created the folder structures in destination, i only to need to map it/create file in that subfolders.  Like condition if folder exists create only file else create folder and file.

  • v-jefferni Profile Picture
    on at

    Hi @Nikhil2 ,

     

    Doesn't need to do that. If the folder exists, it will do nothing but create the file, if folder doesn't exist, it will create the folder then create file in the folder.

     

    Best regards,

  • Nikhil2 Profile Picture
    522 on at

    @v-jefferni What i have noticed now is that, when it creates the file in destination folder. The file is not accessible or it shows the error message to open it.

     

    Nikhil2_0-1713255455823.png

     

  • v-jefferni Profile Picture
    on at

    Hi @Nikhil2 ,

     

    Is this situation only to this word file or to all newly created files?

     

    Best regards,

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard