343

Using a catalog to send the contents of an entire directory

Catalogs can send a group of files to users upon their request without manual intervention.  It may be useful to send all the contents of a directory to a user as part of a catalog.  There is no built in mechanism for this within MDaemon, however, one of our users created a way to accomplish this task with VB script.

First, Create a Catalog the normal way. You don't add any files.

Next, copy the next lines to a .vbs, alter as needed and save it. Now run this .vbs every time the contents of the folder change:

'start of FolderCatalog.vbs
'Put the contents of a folder in a catalog. The magic name is the same as the filename.
'Jochem Baud, 2005. jochem_no@spam_litterarisch.nl

Const CatalogName = 'Name of Catalog'
Const CatalogPath = 'folder where catalog is located, full path, end with \'
Const CatalogPassword = 'password, leave blank if none'
Const MDaemonPath = 'Path to Mdaemon\App\'
Dim objFSO, objFolderObject, objFileCollection, objFile, objFileSystem,
objOutputFile
Dim strOutputFile
Set objFSO = CreateObject('Scripting.FileSystemObject')
Set objFolderObject = objFSO.GetFolder(CatalogPath)
Set objFSO = Nothing
Set objFileCollection = objFolderObject.Files
Set objFolderObject = Nothing
strOutputFile = MDaemonPath & CatalogName & '.cat'
Set objFileSystem = CreateObject('Scripting.fileSystemObject')
Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile, TRUE)
'create the .cat file
objOutputFile.WriteLine(CatalogPassword) 'write the password
Set objFileSystem = Nothing
intNumberOfFiles = objFileCollection.Count
For Each objFile in objFileCollection
objOutputFile.WriteLine(objFile.Name & ', ' & CatalogPath & objFile.Name)
'write the magic name and path
Next
objOutputFile.Close
Set objFileCollection = Nothing
'End of FolderCatalog.vbs

Additional Comments

This configuration is not supported by technical support and is provided for informational purposes only.