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

Alteryx designer Discussions

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

Using events to delete files

Highlighted
Meteor

 Hello,

 

I have the following issue:

I would like to use Events to run a (self-deleting) batch file after every run that deletes certain files (*.bak files as well as a *.xlsm).

 

The batch file looks as follows:

 

if exist "..\Output\Test GmbH - Steuerbescheinigungen\" DEL "..\Output\Test GmbH - Steuerbescheinigungen\*.bak" "..\Output\Test GmbH - Steuerbescheinigungen\Test GmbH - 2018-11-19 13_02 - Hilfsdatei Steuerbescheinigungen.xlsm"
(GOTO) 2>nul & del "%~f0"
@echo off

After running my workflow, Alteryx returns that the event has run successfully.

	Designer x64	The Designer x64 reported: Completed Event #1: After Run: Run 50a EStG - Workflow - Löschen Steuerbescheinigungen Hilfsdateien.bat

However, although the BAT file deleted it self, none of the BAK files were deleted. But when I create the BAT file without the self deleting part and manually execute it after the Alteryx Workflow was finished, the BAK files (and the other file) are deleted correctly - hence, I'm rather confident that the error is not in my BAT file but rather in some kind of misunderstanding I have about how events work.

 

Any help would be appreciated.


Best regards

Moderator
Moderator

Hi @RHehlmann,

 

Thank you for posting!

 

Your batch file is written in a way that DEL command could not show errors (2>nul). Could you please replace null by a file path in order to store the error message?

 

Example:

if exist "..\Output\Test GmbH - Steuerbescheinigungen\" DEL "..\Output\Test GmbH - Steuerbescheinigungen\*.bak" "..\Output\Test GmbH - Steuerbescheinigungen\Test GmbH - 2018-11-19 13_02 - Hilfsdatei Steuerbescheinigungen.xlsm"
(GOTO) 2>%TEMP%\del_error.txt & del "%~f0"
@echo off

Then file %TEMP%\del_error.txt should tell you more about the error. You may try to replace relative paths by absolute paths to see if it changes anything.

 

Kind regards,

 

Paul Noirel

Sr Customer Support Engineer, Alteryx

Meteor

Hi PaulN,

 

Thank you for the quick response. The error message did not return anything useful but your answer got me thinking and I figured out where my understanding of the events were wrong:

 

I save the BAT files in a subdirectory and build the relative file paths accordingly. Manually executing the BAT files yielded the expected results. However, using "Events" the BAT file was run in the same directory as the workflow and, thus, I needed to adjust my relative pathing to the directory of my workflow instead of the location the BAT files are saved. I don't know if I could have achieved the same result but using the "Working directory" in the event options.

Labels