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
how copy a file or folder after is being created
Moderator: Martin
- digitalstone
- Posts: 342
- Joined: 21 Oct 2017 12:36
- Location: The Netherlands
Re: how copy a file or folder after is being created
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"
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"
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.
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, "/")
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]
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)
Re: how copy a file or folder after is being created
thanks, I will try