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
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.
Solved! Go to Solution.
Are you familiar with this error I'm receiving?
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.
Hmmmm still getting this external program error.
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.
@atcodedog05 - looks like you weren't tagged in the above reply, in case you're able to take a look.
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?
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