Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

To create file versions if the file exists in a directory

lumjingbki
8 - Asteroid

I have a workflow that will be used for running multiple times by users  to generate output files with different version whenever the workflow runs. When I output a file I want to check if the file exist if the file exist then add _v1 to the file name and create a new file. if the file name is not there then it should create if file is existing then it should create v1, v2.  Thanks for help in advance

2 REPLIES 2
DanielG
12 - Quasar

@lumjingbki 

 

Use a directory input to bring in items from the folder location.  For example sake, use *.xls* to only pull in Excel files to further whittle it down.

 

Then filter out any extra noise to find the file with the newest version of the name.  Then do a regex match to see if that file ends with "_v\d+".

 

If it doesnt, then add "_v1", if it does then extract the # and add one to it, then reconstruct the suffix and apply it to the name.

 

Then use that as your filepath that makes its way to the output tool and use it to "Replace Entire Path".

 

Cant send screenshot or example, as I'd have to mask my own file paths, etc. and that would take a ton of time.  :)

 

Hope this helps.

Clifford_Coon
11 - Bolide

@lumjingbki ,

 

Another option is to use FileExists(Path) in a formula tool and adjust as @DanielG  suggests.

Labels