Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Moving files to another directory

oce
5 - Atom

Hi all! I need a workflow to periodically check if there are new excel files in a directory, and if there are, they need to be moved to another directory. The workflow I have built (see attachment) works fine if there are any excel files available and moves them to the desired folder, however, it throws the following error if the directory is empty:

 

 

Error: Run Command (17): The external program "%temp%\MoveFiles.bat" returned an error code: 1

 

oce_1-1632320098581.png

 

 

Is there a way to stop/finish this workflow without throwing an error if there are no excel files to be moved? Any help will be greatly appreciated.

17 REPLIES 17
jsilavong
8 - Asteroid

jsilavong_0-1646844516439.png

 

Are you familiar with this error I'm receiving? 

 

Luke_C
17 - Castor
17 - Castor

Hi @jsilavong 

 

Try putting an autofield tool after the formula tool that is creating the command. Based on the warning you're getting that might fix the issue.

jsilavong
8 - Asteroid

Hmmmm still getting this external program error.

 

jsilavong_0-1646863545323.pngjsilavong_1-1646863565495.pngjsilavong_2-1646863637350.png

 

Luke_C
17 - Castor
17 - Castor

Hi @jsilavong That move command syntax doesn't look right, granted I'm definitely not an expert on commands.


The syntax is usually Move "Full File Path" "Destination File Location" 

 

You appear to be missing quotes around the file paths. Can you elaborate on the purpose of the tempfilepath and txt portions? Something like

 

'Move ' + '"' + [FullPath] + '" "'+[TargetPath]+'"' should do the trick. 

Hi @atcodedog05,

 

I am doing a similar thing here, however I am running into the error below. Do you have any advice for this? I have all of my excel files closed.

 

 

jmahoney
Alteryx Alumni (Retired)

@atcodedog05 - looks like you weren't tagged in the above reply, in case you're able to take a look. 

adrilarotta
8 - Asteroid

Hi @atcodedog05,

 

This solution works but only to copy and paste files, how do I remove files from one directory and paste them in another one?

kjsfld
6 - Meteoroid

Hi @adrilarotta : @oce 's workflow works well for directly moving files with that one caveat that it throws an error if there are no files to move.

 

I've modified his workflow slightly to change the TargetPath field and it works well for my use case. For my case, I need to retain the latest file in the same folder folder and move all others to an archive folder. See below for screenshot and for the formula change I made.

 

Formula change:

If [RecordID] = 1
THEN [Directory]

ELSE Replace([Directory],
		"current_folder",
		"new_folder")

ENDIF

 

Change "current_folder" to be the folder your files are currently located in. Change "new_folder" to be the folder you want them to be moved to.

 

 

I hope this helps!

-kjsfld

Labels