community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Community v19.6

Looks aren't everything... But the latest Community refresh looks darn good!

Learn More
SOLVED

Copy a .XLSM Template using a .bat script to two locations and rename the file using .bat

Highlighted
Meteor

I have attached my sample workflow to this post where I am trying to just write a batch file to copy a template .xlsm file to a different location (from the C Drive / Desktop to the C Drive / Documents folder for now - want to perfect this before changing these to my network server locations) and also to rename the copied file with a date suffix. 

 

Please note that in the directory tool I have taken out my "Username" value between "Users\" and "Desktop" and "Documents" to remove my identity from this data - this will likely need to be changed to your username on your computer before you can test this workflow.

 

The workflow is supposed to write a batch script file to the C:\Users\Desktop location that's contents are below and then run that script.bat file as the 2nd part of the "Block Until Done" tool. 

 

xcopy /s "C:\Users\Desktop\FA SUBLEDGER REC - TEMPLATE.xlsm" C:\Users\Documents\
xcopy /s "C:\Users\Documents\FA SUBLEDGER REC - TEMPLATE.xlsm" "C:\Users\Documents\My Received Files\"
ren "C:\Users\Documents\My Received Files\FA SUBLEDGER REC - TEMPLATE.xlsm" FASUBLEDGERREC-TEMPLATE_

 

Unfortunately, I have only been able to get the workflow to output the "output.csv" file and copy the .xlsm file from the Desktop to the Documents folder, but the copy from the Documents folder to the Documents\My Received Files location has never worked and neither has the rename (obviously since the file never gets copies to the "My Received Files" location). I am constantly getting an error code 4 as part of the Run Command, which apparently means the system cannot open the .bat file for some reason.

 

Ultimately, if I am able to get this entire container fixed and working on my C drive, I'm almost positive I can attach this to my workflow where I write three separate Output Tools to 3 separate tabs of the copied .XLSM template file.

 

Thoughts?

Alteryx
Alteryx

Hi @taxguy33 

 

My top tip when working with batch files is to always try to run them outside Alteryx with a pause at the bottom.

 

After doing that I saw:

 

Error.jpg

 

Looking at your command you had /s which means it will include subfolders, and as you were trying to copy a file to a subfolder, it got the cyclic copy error.

 

So I went about removing that, I also needed to add the /Y command to ignore the prompt about overwriting an existing template as well.

 

Lastly I got rid of the output tool and block until done, as you can do the steps needed in the run command tool.

 

Workflow.jpg

 

It will currently still error if you run it twice in a row, as you can't rename the template to an existing file name.

 

For that I'd recommend that instead of copying and renaming, you copy to a new name. But didn't want to go ahead and do that in case that isn't what you want.

Labels