How to 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.
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

  1. Paste this macro into VBA.
  2. Select a Folder in ArcCatalog.
  3. Run the macro.
[VBA]
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
    Else
        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
        Else
            ' 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 = pGxObj1.Name
                
                Set pMD = pGxObj1
                
                'Create or Synch metadata
                pMD.Synchronize esriMSAAccessed, 1
                
                Set pGxObj1 = pEnumGxObj.Next
                intCount = intCount + 1
            Loop
        End If
    End If
    
End Sub