This is just a very small script for deleting folders that have been created by the FDM Batch Processor. When Batch Processor has finished its processing it creates a new folder with today’s date and time as the folder name. After a while the number of these folders can run into the hundreds if not thousands. This simple script will automatically delete any folder in the Batch Processor format that is older than a set number of days (default is 30).
Just copy this file to the Scripts\Custom folder. This is a script file with a .KEY extension. Change the file name to: webDeleteOldBatchFolders.uss. webDeleteOldBatchFoldersUSS
Sub webDeleteOldBatchFolders()
‘——————————————————————
‘Oracle Hyperion FDM CUSTOM Script:
‘
‘Created By: Marcus Hemy.
‘
‘Date Created: 2014-01-07 18:14:58
‘
‘Purpose: Deletes the folders created by the Batch process.
‘
‘ Do not delete folders that were created less than
‘ the number of days held in the variable nDeleteFoldersOlderThan.
‘
‘——————————————————————
Dim TodayAsNumberDays
Dim oFSO, oFolder, oAllSubFolders, oSubFolder
Dim sFolderName
Dim sStartFolder
Dim arrSplit
Dim nDeleteFoldersOlderThan
Dim sMsg
Dim nDeletedCounter
‘=========================================
‘ ADMIN SECTION – START
‘=========================================
‘Number of days.
‘Any folder created more than this number of days ago will be deleted.
nDeleteFoldersOlderThan = 30
‘=========================================
‘ ADMIN SECTION – END
‘=========================================
‘Get today in the form of the number of days since 1900.
‘Could use DateDiff but you need to add 2 to get the correct number of days
‘TodayAsNumberDays = DateDiff(“d”, “1/1/1900”, Now) + 2
‘Alternatively get today’s date as a number.
TodayAsNumberDays = CDbl(Date())
‘Store the name of the Batches folder
sStartFolder = API.DataWindow.Connection.PstrDirInbox & “\Batches\”
‘Use File System Object for handling the folders
Set oFSO = CreateObject(“Scripting.FileSystemObject”)
‘Create an object with the all the information about the folder
Set oFolder = oFSO.GetFolder(sStartFolder)
‘Get a list of all the sub folders in Batches
Set oAllSubFolders = oFolder.SubFolders
‘Go through each folder and examine its name
For Each oSubFolder In oAllSubFolders
‘Store the folder name
sFolderName = oSubFolder.Name
‘Format of the folder name created by the Batch Processor is NumberofDays_NumberOfSeconds
‘If there is an underscore we might be interested
If InStr(sFolderName, “_”) Then
‘Put the folder name into an array by splitting it at the underscore.
arrSplit = Split(sFolderName, “_”)
‘arrSplit(0) will contain the number of days if it’s in the correct format
‘Check if this is a number
If IsNumeric(arrSplit(0)) Then
‘Compare the folder name number of days against today’s date less the number of days parameter
If CDbl(arrSplit(0)) < CDbl(TodayAsNumberDays – nDeleteFoldersOlderThan) Then
‘We want to delete this one.
‘Update the counter
nDeletedCounter = nDeletedCounter + 1
‘Delete the folder
oFSO.DeleteFolder(sStartFolder & sFolderName)
End If
End If
End If
Next
‘Store the output message in a variable and display appropriately.
sMsg = “Deleted [” & nDeletedCounter & “] folders.”
If LCase(API.DataWindow.Connection.PstrClientType) = “workbench” Then
MsgBox sMsg
Else
‘Let the user know we are done
RES.PlngActionType = 2
RES.PstrActionValue = sMsg
End If
End Sub