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

Alteryx designer Discussions

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

Copy Files from One Folder to Another - Workflow on Server

Atom

Does anyone have a workflow solution for copying the contents of one folder into another folder with a Run Command or Event on the Alteryx Server? 

Quasar

This post by @DanM helped me figure out to use the Run command in my applications:

https://community.alteryx.com/t5/Alteryx-Knowledge-Base/Batch-Files-in-Alteryx-Part-3-Deleting-Files...

 

I use the DEL command to delete files after I am done processing them as in @DanM's solution. I think you could use the same logic to do a MOVE command.

 

This link might help with the syntax:

https://www.computerhope.com/movehlp.htm

 

 

 

 

 

 

Atom

@ddiesel Thank you for the reply! That post is definitely helpful in understanding some functions for Batch Files, but in this case doesn't quite give me the insights to copying that I am looking for. 

Quasar

You're welcome @stockcc1. I'm a relatively new user so others may be able to chime in.

 

Can you post more details about your use case?

Comet

To run batch scripts (such as the copy command), I use a set of macros that look like this:

image.png

 

Using a Control Parameter allows me to swap out arguments to my batch script (such as OldFilePath and NewFilePath in this example).

 

Then the batch script is as simple as this:

@Echo OFF
Setlocal EnableDelayedExpansion
cls
SET OldFile=%1
SET NewFile=%2

copy !OldFile! !NewFile!

 

A few notes:

  • The "Setlocal EnableDelayedExpansion" is necessary (if I remember correctly) to handle file paths with spaces.  
  • The dummy output is necessary to properly block downstream data streams if you are using this with a Block Until Done tool (see here for an exhaustive exploration of this issue)
  • You would need to modify this script to copy a whole directory, but the basic mechanism to achieve this is the same.  You just want to tweak the script above using different commands as outlined here
  • If you are copying network paths (which I am assuming you are if you are deploying to server), make sure that all of your paths are UNC based.  We've run into issues with using drive letters when going between local machines and executing on server.  

Hope this helps.

 

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

K.I.S.S.

 

The batch (.bat) file would look like this:

 

MOVE /Y  \\NetworkDriveName\DirectoryPath\*.xls* \\NetworkDriveName\DirectoryPath\Archive

 

That "movefiles.bat" would be run as an event after run without errors and it would move all of the .xls* files.  

 

This being said, there is some level of risk when users start using command line actions on your server.

 

To move one or more files:
MOVE [/Y | /-Y] [drive:][path]file name1[,...] destination

 

[drive:][path]file name1 Specifies the location and name of the file or files you want to move.
destination Specifies the new location of the file. Destination can consist of a drive letter and colon, a directory name, or a combination. If you are moving only one file, you can also include a file name if you want to rename the file when you move it.
[drive:][path]dirname1 Specifies the directory you want to rename.
dirname2 Specifies the new name of the directory.
/Y Suppresses prompting to confirm you want to overwrite an existing destination file.

 

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and reboot. Order shall return.
Labels