Metadata Value based on Filename

Hi All,

is it possible to automatically to get a metadata from a filename

Example:

We have a file named: 123_Michael_2023_Proposal.pdf

When we upload the file, then the metadata will be automatically filled as follows:

  • Cust id: 123
  • Cust name: Michael
  • Year: 2023
  • Doc Type: proposal

Thank you & Looking forward

Parents Reply Children
  • Hi Michael,

    First of all I'd like to add that lately I have used Extension Kit from Unitfly for this type of operation. They have an option to use Regex in a relatively simple configuration that will extract the desired part of string and place it as property value. If you have that option, you should use this rather than scripting - particularly if your vault is in Cloud where scripting needs approval.

    The code below will extract the first segment of a string and place it as property value in an automatic value script. The string is the name of the first file attached to the document.
    You could build on this to make a workflow action script that will extract each of the segments and add them as values to different properties.

    Before you go ahead please check out the options for the split function https://www.w3schools.com/asp/func_split.asp

    '2019.05.28 Karl Lausten
    Option Explicit
    Dim oFileNameSegments
    Dim oFilelist : set oFileList = Vault.ObjectFileOperations.GetFiles(ObjVer)
    If oFileList.Count > 0 then 
    	Dim szFileName1 : szFileName1 = oFileList.Item(1).Title
    	oFileNameSegments = split(szFileName1)
    End if
    'check that number of segments is qreater that or equal to the number required.
    'note that the first segment is item 0, so the count needs to be 1 higher than the segment number wanted.
    if (uBound(oFileNameSegments) + 1) >= 1 then
    	Output = oFileNameSegments(0)
    end if

    Best regards,

    Karl