Hi. I have been using a simple BAT file in the Events of the Workflow Configuration to remove the *.xlsx.bak files with no problems. Now I am being asked to also remove all Excel file 5 days and older from the same folder.
My current BAT file has this:
del "\\main\obx\lifeline\*.xlsx.bak"
Would I be wise to add a second event BAT file and if so, what would be the logic to delete anything five days and older? I have tried different suggestions with FORFILEs and I get errors running the file.
Solved! Go to Solution.
@JPSeagull try using Command Prompt tool. That will work.
@Raj - Yes, I am exploring that tool, but I am trying to find the logic/coding for specifying 5 days and older to delete files from a shared folder.
@JPSeagull
your command should look soemthing like this
@echo off setlocal REM Change directory to the folder where your Excel files are located cd /d "\\main\obx\lifeline\" REM Delete Excel files older than 5 days forfiles /p "\\main\obx\lifeline\" /m "*.xlsx" /d -5 /c "cmd /c del @file" endlocal
also please reffer the attached example to make the configurations.
@raj - the issue is that I load the workflow to our Gallery and it seems that there is a UNC issue and the Gallery doesn't run the FORFILES command.
Like I said, it perfectly runs the batch file to delete the .BAK files. I was hoping to modify that same command without using forfiles. I can load a mockup workflow, but not sure how it will help if the events is pointing to batch file in another shared folder location.
Hi @JPSeagull
One of the ways is to use a directory tool and filter out all the files newer than 5-days. Build a batch file with the following structure and pass it to a Command tool
del "\\main\obx\lifeline\Oldfile1.xlsx"
del "\\main\obx\lifeline\Oldfile2.xlsx"
del "\\main\obx\lifeline\Oldfile3.xlsx"
Dan
@danilang Thank you! That is what I did. I used command tool and created a batch file. Works perfectly!