Page 1 of 1

how copy a file or folder after is being created

Posted: 10 Jun 2018 09:43
by holymoz
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

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

Posted: 10 Jun 2018 12:38
by digitalstone
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.

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

Posted: 10 Jun 2018 15:03
by holymoz
thanks, I will try