11-14-2022 08:37 AM
Hello - I'm trying to find a way to delete multiple folders using the File Explorer Manager (PV650 SV101), but not seeing a way to select multiple. For background, we use a lot of batch data processing, and so our File Share\Applications\Batch folder grows quickly, so deleting these folders one at a time is not going to be possible, so perhaps I'm overlooking an easy way to do this in the FEM module? Or via a DataManager sequence / BR?
Thanks for any feedback,
11-14-2022 10:11 AM
I don't have any code samples handy, but this will an Extensibility BR, triggered by "Execute Business Rule" Data management sequence, that you want to schedule in Task Scheduler.
The BR logic is the follows:
1) Declare your batch folder
2) Loop thru all subfolders to get the creation date;
3) If the date is greater that certain predefined value (use DateDiff method), then simply delete the folder. You can do it using either .NET IO object or OS generic method.
I would pass the said predefined value (number of days) as theTask manager parameter.
02-03-2023 12:52 PM
Hi,
Agree, we're in the same situation, multiple files can't be deleted, copied or moved at once, needs to be one by one. Good advice to create a business rule, just we need to be able to execute multiple actions in a graphic way.
Thanks,
CR
yesterday
Not exactly the solution you are looking for, but I created this BR that can be used to clean up the folder structure inside the BatchHarvest structure, maybe it can be inspiration?
'****************************************************************************************************************************
' This helper rule was created in order to facilitate a quick and easy way to Archive the contents in the Batch
' folder. This will Create an Archive folder, with subfolders for years, which includes subfolders for months
'
' Simply run this, or use a DataManagement Step to schedule it
'
' Created 2021-02-03 by Joakim Kulan
'****************************************************************************************************************************
Select Case args.FunctionType
Case Is = ExtenderFunctionType.Unknown, ExtenderFunctionType.ExecuteDataMgmtBusinessRuleStep
Dim batchpath As String = BRApi.Utilities.GetFileShareFolder(si, Filesharefoldertypes.Batch, Nothing)
Dim subfolders As IEnumerable(Of String) = From chkFolder In Directory.EnumerateDirectories(batchpath)
Dim Counter As Integer = 0
For Each subfolderpath As String In subfolders
If Not (subfolderpath.XFContainsIgnoreCase("Harvest") Or subfolderPath.XFContainsIgnoreCase("Archive")) Then
Dim subfolderName As String = subfolderpath.Substring(subfolderpath.LastIndexOf("\") + 1)
Dim newSubFolderpath As String = batchpath & "\Archive\" & left(subfolderName,4) & "\" & left(subfolderName,6)
If Not Directory.Exists(newSubFolderPath) Then
Dim Di As DirectoryInfo = Directory.CreateDirectory(newSubFolderPath)
End If
Directory.Move(subfolderPath, newSubFolderPath & "\" & subFolderName)
Counter += 1
End If
Next
Dim errormsg As New Text.StringBuilder
errormsg.Append("*** XFJ ArchiveBatchFolder Status: ***")
errormsg.AppendLine("")
If Counter > 0 Then
errormsg.AppendLine("Batch folder archiving completed. "& Counter.ToString &" folders successfully archived")
Else
errormsg.AppendLine("Batch folder archiving completed. Found no folders to archive")
End If
errormsg.AppendLine("")
brapi.ErrorLog.LogMessage(si, errormsg.ToString)
End Select
Return Nothing