Is there a way to append a file with (2) if a file with the same name already exists? Currently, the 'Move a File' connection for Box.com errors out if a file with the same name exists and the entire workflow ends.
THANKS!
Is there a way to append a file with (2) if a file with the same name already exists? Currently, the 'Move a File' connection for Box.com errors out if a file with the same name exists and the entire workflow ends.
THANKS!
Best answer by Ken_T
Well... there actually -is- a solution, but its tedious and takes a lot of actions. I'm currently doing this for all Box movement functions within my workflows, and have made a component workflow just for box file movement.
1) Store the filename as a variable (will will be disecting this later)
2) Set a variable to track how many times you've been through the loop
3) Use "Box - Get Folder Contents" to store a collection of all objects in the target folder.
4) Begin a loop that will exit once a unique filename has been determined
5) Use "Check if item exists in a collection" to determine if the intended filename is already in the target folder (from step 3)
6) Use "Logic and flow - Branch by condition" to have a separate path for an OK filename vs. a conflicting filename
7) on the OK file name path, simply move the file and exit the loop
8) on the conflicting filename path, break apart the filename into 2 separate variables using Regex. The base filename should be a regex of .[^.\/:*?"<>| ]+$ The file extension should be a regex of [^.]+$
9) create a new filename by adding the filename & "_" & the LoopCounter & the filenameExtension.
10) end the loop
By modifying the filename in step 9, the next time the loop completes the filename will now be named "mytextfile_1.txt" after the first loop if there is already a "mytextfile.txt" in the folder. It will repeat the loop until a conflict is not present.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.