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
  • I have done that quite a lot using a script. You can use the Split function to get an array of those 4 values and then add them to the appropriate properties.
    Cust id and Cust name are probably both related to a customer object type. In that case it would be enough to add Cust id in the script and then retrieve Cust name as an automatic value.
    Doc Type is probably related to a value list. If you cannot be certain that the value is typed in the file name exactly as it is in the value list you may need to use a search function to get the correct lookup id.

  • Dear Bright,

    Thanks for your idea, any example of the script that i can try?

  • 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

Reply
  • 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

Children
No Data