none
How can I extract metadata from file names? RRS feed

  • Question

  • If I want to extract metadata from file names? How can I do that? I want to read through the file names and when I get to a certain character ("-"), I can take the string just before that character and store it in a column in SharePoint. Is this do-able through scripting? 
    Thursday, March 5, 2015 6:56 PM

Answers

  • If I want to extract metadata from file names? How can I do that? I want to read through the file names and when I get to a certain character ("-"), I can take the string just before that character and store it in a column in SharePoint. Is this do-able through scripting? 

    You should be able to leverage the split method.

    In PowerShell It would look like:

    # Gather the file name $file = "myawesome_filename-Month-Day-Year-Ect.doc" #split the file name by the "-" character $file = $file.split("-") # Use a foreach Loop to gather the individual items. foreach ($item in $file) { write-host $item } #Output

    myawesome_filename Month Day Year Ect.doc # If you want to only grab the first item, you can do $file[0] <-- powershell starts counting with zero base. $file[0] #output myawesome_filename



    Entrepreneur, Strategic Technical Advisor, and Sr. Consulting Engineer - Strategic Services and Solutions Check out my book - Powershell 3.0 - WMI: http://amzn.to/1BnjOmo | Mastering PowerShell Coming in April 2015!





    • Edited by Brent Blawat Thursday, March 5, 2015 7:42 PM
    • Marked as answer by Spawn10 Saturday, March 14, 2015 11:27 PM
    Thursday, March 5, 2015 7:36 PM