We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Dynamically Rename Output File that Exists

caltang
17 - Castor
17 - Castor

Hi there, 

 

This is my use case:

image.png

 

Let's assume TestOutput_19092023 already exists in a fixed folder somewhere in my PC. 

 

My Input file changes every single day. 

 

Now, my output file should ideally be updated every day I run this. I am trying to reduce manual work by renaming the output file each run before I run my Workflow on Alteryx.

 

Is there a way to run the workflow referencing the existing output file, then rename it dynamically to the date which I want it to be renamed to? (More flexible).

 

Thanks!

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
9 REPLIES 9
Peachyco
11 - Bolide

In my Windows environment, I can accomplish this by using the REN command with the Run Command Tool. You might have to look for the equivalent command if you're using a different environment.

caltang
17 - Castor
17 - Castor

Interesting! Can you share how we can accomplish this in Alteryx with the Run Command tool?

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
caltang
17 - Castor
17 - Castor

Thanks @ChrisTX for the links! But they do not really answer my need - I'll bookmark it for future referencing when I find a relatable use case.

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
caltang
17 - Castor
17 - Castor

@Peachyco your solution works! Ren is what I need with Run Command.

 

Please refer to the great work of @DavidP from 2019: https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Renaming-files-at-system-level...

 

Also related: https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Rename-a-file-after-processing... 

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
Peachyco
11 - Bolide

This is my workflow:

Alteryx - caltang Dynamic Rename a.png

 

These are my parameters (i.e. my starting data):

Alteryx - caltang Dynamic Rename b.png

 

This is my formula. Note the use of double quotes to account for the possible whitespace in the file paths and names:

Alteryx - caltang Dynamic Rename c.png

This is how I'm concatenating with the Summarize Tool. This needs to happen because the line "exit 0" must be in a new line, after the Rename command. Note the separator character I'm using.

Alteryx - caltang Dynamic Rename d.png

 

Next, I write the batch file. Here it's named "renamer.bat".

Alteryx - caltang Dynamic Rename e.png

 

And finally, I execute the batch file thru the Run Command Tool. Because I wrote the .bat in the temporary folder, I have to reference that temporary folder here.

Alteryx - caltang Dynamic Rename f.png

caltang
17 - Castor
17 - Castor

Much appreciated, thank you my friend @Peachyco !

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
Shaaz
9 - Comet

how to avoid error in run command tool if there's no file present in a folder to rename.

ChrisTX
16 - Nebula
16 - Nebula

@Shaaz you could add a regular Filter tool in Alteryx before the Run Command tool, with Filter code like this:

 

IF FileExists(C:\Temp\Data\file.csv) THEN 1      

ELSE 0

ENDIF

//the "1" sends output through the True output anchor

 

Chris

Labels
Top Solution Authors