Create Metadata for All in Folder


This tip demonstrates how to create metadata for all items in a selected folder.

To use, select a folder in the ArcCatalog Table of Content. By running the macro, metadata will be create for all objects in the Folder that support metadata.

NOTE: this macro doesn't verify that the selected object supports metadata, whether it already has metadata, or whether the metadata is writable.

How to use:
Sub MetaData_Synch
'Methods: IMetadata.Metadata, IMetadata.Synchronize
'Purpose: For all data items contained in a folder, Create metatdata
    Dim pGxApp As IGxApplication
    Dim pGxSel As IGxSelection
    Dim pGxObjectCont As IGxObjectContainer
    Dim pEnumGxObj As IEnumGxObject
    Dim pGxObj As IGxObject
    Dim pGxObj1 As IGxObject
    Dim pMD As IMetadata
    Set pGxApp = Application
    Set pGxObj = pGxApp.SelectedObject
    If Not TypeOf pGxObj Is IGxFolder Then
        MsgBox "Please select a Folder", vbExclamation
        Exit Sub
        Set pGxObjectCont = pGxObj
        'Check to see if there are children
        Set pEnumGxObj = pGxObjectCont.Children
        If pEnumGxObj Is Nothing Then
            MsgBox "Nothing was found in the  " & pGxObj.FullName & " Folder"
            Exit Sub
            ' For each object that is in the Folder, 	
	    ' create metadata using the synchronize method
            Set pGxObj1 = pEnumGxObj.Next
            Dim intCount As Integer
                Do While Not pGxObj1 Is Nothing
                    Dim strName As String
                    strName =
                    Set pMD = pGxObj1
                    'Create or Synch metadata
                    pMD.Synchronize esriMSAAccessed, 1
                    Set pGxObj1 = pEnumGxObj.Next
                    intCount = intCount + 1
        End If
    End If

End Sub