Hi there,
This is my use case:
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!
Solved! Go to Solution.
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.
A few posts that may help:
How to: Dynamically rename output files
https://community.alteryx.com/t5/Alteryx-Knowledge-Base/How-to-Guide-to-dynamically-renaming-output-...
Saving an Excel File with Today's Date
Community > Designer > Browse Knowledge > Saving an Excel File with Today's Date
Use BAT file to rename folder or file:
https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Using-Run-Command-to-Move-files/td-p/8...
https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Input-File-AUDIT-Issue/td-p/452077
Chris
Interesting! Can you share how we can accomplish this in Alteryx with the Run Command tool?
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.
@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...
This is my workflow:
These are my parameters (i.e. my starting data):
This is my formula. Note the use of double quotes to account for the possible whitespace in the file paths and names:
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.
Next, I write the batch file. Here it's named "renamer.bat".
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.
Much appreciated, thank you my friend @Peachyco !
how to avoid error in run command tool if there's no file present in a folder to rename.
@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