Free Trial

Alteryx Designer Desktop Discussions

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

How do I use run command to copy a file and paste it into a dynamic folder?

helenjin1
8 - Asteroid

Hi everyone, 

 

I want to use the run command tool and batch files to copy a file from my Engine.WorkflowDirectory to a folder inside the same directory, except the folder name updates with the date.

 

This is what I have written for my batch file (although I really don't know how to write the second part):

 

@Echo OFF
copy /y "%Engine.WorkflowDirectory%OB_zip.zip" "%Engine.WorkflowDirectory%[FolderName]"
Pause

 

The folder name is some variation of Output_YYYY-MM-DD.

 

I've attached an image of the part of the workflow I'm stuck on for reference:

 

6 REPLIES 6
LordNeilLord
15 - Aurora

Your syntax looks correct but i'm not sure copy can create new directories (presuming thats what you need)

 

Try xcopy instead which can.

 

Also, when experimenting with batch files, try running each part of your script in command prompt first to test as you will get proper errors rather that error code 1 from Alteryx

helenjin1
8 - Asteroid

Thanks for the reply!

 

No, I used another bat file and run command tool to create a directory with the file name [Folder Name]. I don't know if using [Folder Name] will translate over to batch files though? 

helenjin1
8 - Asteroid

Actually, I think it's a problem with my run command tool. When I run the batch file in my computer it copies and pastes the file correctly. But when I run it through my run command tool I get an error saying the bat file is not a known format?

 

 

danilang
19 - Altair
19 - Altair

Hi @helenjin1 

 

You need to change your formula for the copy command to 

 

 

'copy /y "' + [Engine.WorkflowDirectory] + 'OB_ZIP.Zip" ' + '"'+ [Engine.WorkflowDirectory] + [foldername]+ '"'

 

 

The %Engine.XXX% variables will only be expanded when you're running a command directly within Alteryx.  In a batch file, your need to specify the full path 

 

Assuming you had "temp" in the [foldername] field, the formula from above will create 

 

 

copy /y "C:\Program Files\Alteryx\bin\OB_ZIP.Zip" "C:\Program Files\Alteryx\bin\temp"

 

 

which will run properly in a batch file

 

Dan

helenjin1
8 - Asteroid

Thank you for the reply!

 

Sorry it doesn't seem to be working for me. Could you post an example workflow?

helenjin1
8 - Asteroid

I figured it out. My Output was not in any specified format. I changed it to csv. and everything worked out smoothly!

Labels
Top Solution Authors