how copy a file or folder after is being created

Post your questions and help other users.

Moderator: Martin

Post Reply
holymoz
Posts: 113
Joined: 13 Sep 2013 10:27

how copy a file or folder after is being created

Post by holymoz » 10 Jun 2018 09:43

hi, can I do this? I'm in a folder called AAA, every time a file or a subfolder is created in this AAA, must be copied in another specific folder.
must be copied ONLY the file or subfolder just created in AAA, not the entire content of the folder AAA, thanks

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: how copy a file or folder after is being created

Post by digitalstone » 10 Jun 2018 12:38

For the trigger, use "File Observer" and check ONLY "Subfile Created"
In the helpsection of this trigger you'll see that this doesn't only register a created subfile but a subfolder as well.
Browse or type in the folder you want to observe (path of your AAA-folder).

Then you have to determine if the flow was triggered by the creation of a file or folder.
Just check this with condition "Expression"

Code: Select all

endsWith(path, "/")
Then branch that condition from 'true' if it's a folder, and 'false' if it was a file.

Continue with the folder-branch with:
Use action "Create Directories".
Inside the field "Directories" you put the path of the "specific folder" you mentioned to be the destination folder.


Continue with the file-branch with:
Use action "Script"

Code: Select all

pathDest=split('specific_folder','\\/');
fileName=pathDest[length(pathDest)-1]
Use action "Copy File".
Inside field "Source File": {path}
Inside "Target File": (path of your specific folder){fileName}


Also you should leave the flow execution policy on "Wait until the current instance has finished" so that multiple sub-files and folder can be handled one after the other.
I haven't tested any of this, i'll leave that part up to you. So be careful.
But at least there isn't any deletion going on so you should be fine.
Last edited by digitalstone on 10 Jun 2018 15:21, edited 1 time in total.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

holymoz
Posts: 113
Joined: 13 Sep 2013 10:27

Re: how copy a file or folder after is being created

Post by holymoz » 10 Jun 2018 15:03

thanks, I will try

Post Reply