Skip to main content

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!

 

@poppy Currently this is not possible, you could have it overwrite but that is really only the current option. You can suggest functionality over on our uservoice(https://nintex.uservoice.com/) 


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.  



 



 


@Ken_T  Thank you for taking the time to explain your solution. I was able to built it out and will be able to use it! Thanks so much again. 


Thanks, Im glad it will help you out!

For anyone that is using a solution similar to what I described above; please be aware that Nintex currently only supports searching through 200 entries in a folder.  if you have more than 200 items (files + subfolders) then the Nintex connector will act as if there are only 200.   This can lead to errors where the WF doesn't realize there is a duplicate file name, but the duplicate is past the Box API's pagination value (200). 



 



I've started a feature request to add support for paginated responses in Connectors.  Feel free to add a vote to that request if you use any methods like I described to loop through contents. 



 



https://nintex.uservoice.com/forums/430063-5-nintex-workflow-cloud/suggestions/40062262-add-support-for-paginated-responses-from-connector


Hey @Ken_T , 



 



Re this: 
1) Store the filename as a variable (will will be disecting this later)

Is that something you could share? I'm having trouble pulling the filename from a "file upload" action in NWC. I can pull this by getting an item from the attachment collection, but not sure how to regedit that down to just filename. 
String: {"connectionId":"555555","path":"/NintexWorkflowCloud/6ec10e98-2e3e-430e-9cfc-73f551714ab9_1_1/empPhotoExample3.jpg"}


I have not had great luck parsing the NWC files collection.  My example used the Box.com file object which you can get attributes from much easier. 



 



I think this Regex might get you started.  From your sample string this regex: /(?:.(?!/))+$  will return this string: /empPhotoExample3.jpg"}



 



From there, you know you need to remove the first character, and the last two characters which is a much simpler operation. 



 



Hope that helps. 



 


Reply