How do I use run command to copy a file and paste it into a dynamic folder?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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:
Solved! Go to Solution.
- Labels:
- Dynamic Processing
- Run Command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you for the reply!
Sorry it doesn't seem to be working for me. Could you post an example workflow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I figured it out. My Output was not in any specified format. I changed it to csv. and everything worked out smoothly!
