Alteryx Designer Desktop Discussions

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

Deleting old input files

StephenT
8 - Asteroid

Hi all

I have seen a few posts regarding the deletion of "old" input filers then running the workflow, or as a cleanup after the workflows have been run, but can't seem to locate solution for my requirements.

I need to be able to delete all files in a specific folder, older than 48 hours (new files are created every Monday and Thursday).

The only issue I can see is the folder name has both spaces and an ampersand ('&') [e.g. G:\Shared drives\AU Desktop Support National\Operational & Reporting\Departers\Input files], which is causing a 'parse' error when/if I use the formula tool 


There are 10 files in the folder consisting of either  ZIP or XLSX files, does not contain any subfolders and all files can be completely deleted.

The "Directory Tool" is recognising the directory structure correctly

StephenT_1-1646266815982.png


Can anyone offer a suggestion as to fixing the parse error, so the files can be deleted ?

11 REPLIES 11
gabrielvilella
14 - Magnetar

Please share what is the error you are getting and how the formula tool was configured. 

StephenT
8 - Asteroid

Hi @gabrielvilella 

Apologies for the omission

here is a screenshot of the test workflow, plus the error message

StephenT_0-1646690738015.png

 

 

 

Luke_C
17 - Castor

hi @StephenT 

 

Based on the error message, you probably have your quotes mixed up in the formula tool. Can you share the formula? 

StephenT
8 - Asteroid

Thanks @Luke_C 
It's highly possible I've mixed the quotes. 😄

StephenT_0-1646691303713.png

 

Luke_C
17 - Castor

Hi @StephenT 

 

Do you actually have a field in your workflow called 'G:\Shared...'? The brackets indicate a field that Alteryx should look for. The error is saying that the field doesn't exist. 

StephenT
8 - Asteroid

Thanks @Luke_C 

"G:\Shared drives\AU Desktop Support National\Operational & Reporting\Departers\Input files" is the directory, from the directory tool. It's not a file or field.
That means the formula should read as 'del /f ' +'"' + [FullPath] +'"' - that was totally my fault

 

When i now run the workflow it works up to that point, then fails when it outputs to the batch file, so thank you for your guidance

 

The other (hopefully small) issue i have is it appears that the workflow is truncating the files names/folders when exporting to the batch file, causing the batch file to fail.

StephenT_0-1646697330803.png

 

Does anyone know how to stop the folders/files from being truncated ?

 

I have also attached the WorkFlow for reference.

Any guidance/.help would be immensely appreciated

Luke_C
17 - Castor

Hi @StephenT 

 

Increase the length of the field

Luke_C_0-1646745471316.png

 

StephenT
8 - Asteroid

Thanks @Luke_C 
I never saw that function, or thought to look for it.

I'll test it later today, and mark it 'accepted as a solution' when it works.

Thanks again

adarsh2707
8 - Asteroid

I have a question on this, would it be possible to parameterize the directory path. So in this situation its just one folder, What if I need to dynamically pass in the parameter for input path to delete older files - with the help of maybe a configuration file that tells which folder to delete files from.

Is this possible

Labels