Alteryx Designer Desktop Discussions

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

Rename Files in a Directory

G_Elson
6 - Meteoroid

Hello! I have a directory containing several files that undergo a lengthy workflow process. At the end of this process, I receive all the outputs needed. However, I would like the system to automatically rename these files in the directory (not the output files) according to a specific naming scheme once the workflow is completed.

 

I have a spreadsheet that includes two columns: one labeled `FullPath` containing the current names of the files, and another labeled `FinalFullPath` with the desired new names for these files. I do not want to create copies of the files; I only want to rename the existing ones.

 

Is this possible to implement?

4 REPLIES 4
SPetrie
12 - Quasar

You can create a rename cmd and use a run tool to execute a batch file that will rename them

I attached a sample workflow that works when I tested it.

The rename cmd is "Ren <original file path w\ file name and ext> <new file name w\ext>" so you dont really need the full path for the new name, just name and extension.

a formula to build the cmd would look something like this for you.

 

'Ren "'+[FullPath]+'" "'+FileGetFileName([FinalFullPath)+FileGetExt(FinalFullFath)+'"'

G_Elson
6 - Meteoroid

It did work! However it did come back with "Run Command (147) The external program "...\Local\Temp\1\Engine_9804_81afe57ea8839f46be02e299b2a541a7_\renamebat.bat" returned an error code: 1" is there a way I can correct this? Also, should this work on an Alteryx server?

SPetrie
12 - Quasar

 

Glad you were able to get it to work.

I get that error sometimes as well. if you union exit /B as the last command of the bat, it should clear/ignore the error

exit.PNG

 

I use multiple workflows that rename and or move files using this method on server, so it can be done. Just make sure that the file locations are accessible to the account that is running them.

Most local server accounts dont have access to network locations by default so the files should be in a place where it or your default server account does have access. Or your need to use stored credentials or have users supply their own.

G_Elson
6 - Meteoroid

Thank you so much for your help!

Labels