How do I bulk upload documents using PowerShell and extract metadata from file name?

I have a requirement to upload a bunch of documents into a document library. Based on the content type, the rules of updating the metadata is different...the one giving me trouble is to extract the metadata from the file name. If I have a file name like
"part1_part2_part3.pdf" how do I extract part1, part2, part3 and tag each document being uploaded into SharePoint, using PowerShell? I have searched and have not been able to find anything to get me started.
Has anyone done this before? Or is there a blog I can take a look at? Thanks
 

You will have to write a PS script encompassing this logic.
Read files from the folder using
Get-Item cmdlet
Determine the content type based on the path or filename.
Split the file name to extract the tag names.
If the metadata fields in the content type is a managed metadata field, check whether the term exists and set it.
Updating SharePoint Managed Metadata Columns
with PowerShell
This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

Similar Messages

  • How can I extract metadata from file names?

    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? 

    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
    #Outputmyawesome_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!

  • Uploading document using Powershell is throwing error- There is no file with URL

    Hi.
    I am trying to upload multiple documents to a sub folder in a library using powershell.
    I am getting the error as : ForEach-Object : Exception calling "Add" with "3" argument(s):
    "<nativehr>0x80070003</nativehr><nativestack></nativestack>There is no file
    with URL 'server/TestLibrary/User_image/ab_3f_wht_ist_small_gif.gif' in this Web."
    I have used the below code:
    function UploadImages($weburl)
    $docLibraryName = "TestLibrary"
    $localFolderPath = "C:\Users\Imgs\user_image"
    Add-PsSnapin Microsoft.SharePoint.PowerShell -erroraction silentlycontinue
    $web = Get-SPWeb -Identity $webUrl
    $docLibrary = $web.Lists[$docLibraryName]
    $subFolderName="user_image"
    Add-PsSnapin Microsoft.SharePoint.PowerShell -erroraction silentlycontinue
    $web = Get-SPWeb -Identity $webUrl
    $docLibrary = $web.Lists[$docLibraryName]
    #Attach to local folder and enumerate through all files
    $files = ([System.IO.DirectoryInfo] (Get-Item $localFolderPath)).GetFiles() | ForEach-Object {
    #Create file stream object from file
    $fileStream = ([System.IO.FileInfo] (Get-Item $_.FullName)).OpenRead()
    $contents = new-object byte[] $fileStream.Length
    $fileStream.Read($contents, 0, [int]$fileStream.Length);
    $fileStream.Close();
    write-host "Copying" $_.Name "to" $docLibrary.Title "in" $web.Title "..."
    #Add file
    $folder = $web.getfolder($docLibrary.Title + "/" + $subFolderName)
    write-host "folder is " $folder
    $spFile = $folder.Files.Add($folder.Url + "/" + $_.Name, $contents, $true)
    $spItem = $spFile.Item
    Write-Host -f Green "Added Images to Library !!!"
    $web.Dispose()
    How to fix this?
    Thanks

    HI,
    Is the name of the image or the sub folder name the issue?
    I have the images with the name as "ab_3f_wht_ist_small_gif.gif".  folder name "User_image"
    There are underscores on the file name, but there is no space. When I add the file from the library (using the UI), the image is getting added.
    But adding through the powershell is giving the issue.
    I have checked this:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/e810ad03-81ef-4fa6-aab8-ddc896a13ebf/getting-error-during-uploading-a-document-using-powershell?forum=sharepointdevelopmentprevious
    but did not help.
    Thanks

  • Re: Use PowerShell to Find Metadata from Photograph Files

    Hi,
    Just read the new blog and thought i'd try it.
    I got as far as setting and calling the $picMetaData for a folder. It didn't list anything when i just has a TIF file in there but when i created a jpg version of the same file it listed the details of both. Tried deleting the jpg and back to no listing.
    Apologies if i'm missing something as a Powershell lightweight
    It might be worth mentioning that the original file was a georeferenced TIF but if it is relevant, it seems odd that it returned a listing when the jpeg version was present.
    Apologies also for asking this on the blog - i realise i should have come here first.
    Andy

    Here is a version that works for one folder and produces consistent CSV files.  It only enumerates the first 66 tags but that covers 99% of all tags.
    You have to understand that each folder will have different metadata.  Thi is determined by the folder contents.  When we ask for GetDetailsOf the folder object the shell scans the files and merges all metadata into the results.  If we scan
    a different folder we will not likely find data names that match.  Much of this is determined by the providers that are installed to the shell.
    The code will also list all files and not just image files.  We could put in a filter using Get-ChildItem.
    Here is the code: http://sdrv.ms/1gQr1B8
    ¯\_(ツ)_/¯

  • Any developers here? How to programatically extract metadata from files..

    In addition to its asset management and workflow automation features, I plan on using FCS to extensively tag media clips with 10-15 metadata fields. Are there any online guides that describe how the metadata is stored in the file? I need to write a script that can extract the metadata fields from these clips, but I'm not really sure where to begin.

    The simplest way is to use the Write XML response. This outputs all the fields and their values associated with an asset to an XML file.
    The other way is to us a Script response. If you know how to write a script (bash, perl, python, ruby, or anything else that is executable on the Mac hosting your installation of FCSvr), you simply leave open variables that match the fields you wish to extract and then call them within the script response's command parameters with your field names in square brackets. Apple has posted sample code on ADC.
    Incidentally, the metadata for FCSvr is held in a PostgreSQL database. The media files themselves do not carry the metadata with them (except for some limited exceptions).

  • How do I store an Int, a short, and multiple bytes from file in byte array

    I'm attempting to do this for a project but can't figure out how to store the three values in one byte array. This is what i've tried
    public void send(byte[] input)
              // TODO
              ByteArrayInputStream bais = new ByteArrayInputStream(input);
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              DataOutputStream dos = new DataOutputStream(baos);
              byte[] pData = new byte[100];
              try {
                   dos.writeShort(checkSum);
                   dos.writeInt(nextSeqNum);
                   pData=baos.toByteArray();
                   bais.read(pData);
              } catch (IOException e) {
              DatagramPacket dgp = new DatagramPacket(pData, pData.length);When i set pData=baos.toByteArray() it changes the size and then stops me from being able to read the other 94 bytes into the array to send. Any ideas?

    You don't need the ByteArrayInputStream at all.
    dos.writeShort(checkSum);
    dos.writeInt(nextSeqNum);
    dos.write(input);
    pData = baos.toByteArray();
    When i set pData=baos.toByteArray() it changes the sizeNo, it makes it refer to a new byte[] array containing what you've written to the BAOS. That's what it's supposed to do.

  • How to Upload documents using Gateway Service in SAP UI5?

    Hi Team,
    How to upload documents using Gateway Service in UI5 app.
    This is Attachment Functionality.using Gateway Service in Controller.JS/View.JS.
    Thanks in Advance.
    Regards,
    Satya

    Hi,
    I suggest you use the search function on scn/google...
    Anyways, here are some usefull links:
    How To Upload and Download Files Using SAP NW Gateway SP06
    Uploading files to SAP using HTML5 /AJAX/Gateway media links with real-time progress bar
    Kind regards,
    RW

  • I am trying to upload documents using Mass Transit but I am getting an Error:"[-192]" message. How can I fix this?

    I am trying to upload documents using Mass Transit but I am getting an Error:"[-192]" message. What is this error? How can I fix this?
    Thank you,

    I've never heard of that product before, but it seems to be, among other things, a 32-bit browser plugin. If that's the part you're having trouble with, quit your browser (e.g., Safari), select its icon in the Applications folder, open the info window, and check the box labeled "Open in 32-bit mode." Relaunch the browser and try again. If that doesn't help, contact the developer for support.

  • Plug_in:how to unlock a locked document use acrobat API

    how to unlock a locked document use acrobat API.in acrobat plug_in

    how to unlock a locked document use acrobat API.in acrobat plug_in(Which API can enter a password to unlock the locked document)

  • How to get Systemstate Backup size using PowerShell command in Windows 2008 R2

    Hi,
    We using WBSummary command to get completed backup status.
    I need to find how much data is backed up  using powerShell command .
    Is there any way to get the details , i can see the GUI but no in command.
    Please advise
    Regards Gopi K

    Hi,
    You mentioned that you can see the system state backup size in the GUI. Does the backup size mean the amount of date transferred?
    It seems that there is no such a PowerShell to get Systemstate Backup size. You may need to you need a PowerShell scripts to do this work.
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/home?forum=ITCG
    Regards,
    Mandy
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Reg:how to post the parked documents using BDC

    Duplicate message in General deleted.  Please do not post the same question in more than one forum.
    Hi
    I am creating parked Documents using FV50. I am able to check them using FBV0, I am able to select and post the documents using the same transaction. Its working fine. However I want to post the selected parked documents using BDC. I am having problems as the output in FBV0 is in ALV report format. HAving problems selcting the parked documents to be posted. As there any way to post the selected parked documents using BDC.
    Please suggest me a solution for this.
    Thanks,
    Satish
    Edited by: Matt on Dec 3, 2008 7:40 PM

    Hi Rob,
    Thank you for ur reply, can u send that code how u post the parked documents using BDC for FBV0 transaction.  Please send the code.
    Thanks,
    Satish

  • Uploading documents using CFFile

    I am using CFFile for uploading documents using Cold Fusion 8
    in my Intranet environment. Each record has a limit of 20 documents
    that can be uploaded into MySQL database. It seems if I upload
    mulitple documents at around 1mb it takes less than a minute to
    complete. The problem seems to be when I upload muliptle documents
    that are bigger.
    If I attempt to upload 2 documents each over 25mb it takes
    around 10 minutes.
    Anyone have suggestions on alternatitve way to do this or
    should I just limit size of each upload to 4mb and less?

    Isn't this just a product of your internet speed and the size
    of the upload?

  • I have just purchased a MacBook Pro and iWork's. when I try to upload documents using iCloud, it now wants me to purchase iWorks for iOS ? Do I need to purchase both versions?

    I have just purchased a MacBook Pro and iWork's. When I try to upload documents using iCloud, it now wants me to purchase iWorks for iOS ? Do I need to purchase both versions?

    To be able to use documents at iCloud.com, you need at least one iOS device that uses the same account with at least one of the iWork apps installed.

  • I downloaded adobe create a pdf- now how do I get a document to connect and be converted

    I downloaded adobe create a pdf- now how do I get a document to connect and be converted

    Hi powerequipsales,
    Create PDF is an online service which you have subscribed.
    Please use below link to access your Create PDF service.
    https://cloud.acrobat.com/convertpdf
    Login with your Adobe id and password associated with it.
    Follow these steps to create a PDF file.
    'Select Files To Convert To PDF' -> 'Choose Files From My Computer'.
    Select the desire file you want to convert in a PDF and click 'Open'.
    Regards,
    Florence

  • I have 2 Macs - an iMac that holds my entire iPhoto library and a Mac Book Pro that I use to hold a subset of the main library - how can I transfer photos and their metadata from the main library of the iMac to my Mac Book?

    I have 2 Macs - an iMac which holds my main iPhoto library and a Mac Book Pro which holds a subset of the library. How can I transfer photos and their metadata from the main library to the smaller 1 on the Mac Book Pro?

    Link the two Macs together and use iPhoto Library Manager
    Regards
    TD

Maybe you are looking for

  • Iphone 6 plus pre-order delivery

    Hi everyone! I pre-ordered my iPhone 6 Plus (64GB Space Gray) on Sept 12th as early as I could (at 4:30 A.M. through the apple store app on my iPhone 5). I tried to order it earlier, but as many of us know the Apple store online was down. I was so ve

  • Every time I click on a link in safari, an ad page pops up

    Hello, I have a MacBook Air (13-inch, Mid 2013) and I am using MacOsX Yosemite edition. A few hours ago something's happened to my safari and almost every time I click on a link, an ad opens up in a tab. When I search something from the address bar,

  • Don't have 2560x1440 resolution on Dell U2711

    Hi, I've recived the mac today and I have a monitor DELL U2711. The monitor is connected with an HDMI cable. This is what I can set now. Someone know what I can do to get 2560x1440 resolution? Thanks Ivan

  • Problems installing My SAP Netweaver 7.01 ABAP Trial

    Hello everybody, I'm Leandro from Brazil and I'm having a problem when I try to install the version 7.01 of NW. When I start the setup, all goes fine, but when it comes to 18% (installing the MaxDB server) it all stop and freeze. I'm trying to instal

  • "2 Photos have been found in the iPhoto Library that were not imported."

    Sorry for re-posting a problem that has been answered and appears to be easily solved. However, I for some reason, can't find my iPhoto Library nor an 'import' or 'importing' folder or file that resembles iPhoto (only something to do with AIM). The o