10

Salvete! How can I, from the commandline, upload a file to a document library? Now, I found davcopy, which works, sort of. I can only upload the file using my domain account that I am already logged in with. If I give credentials (even my own!) the fail.

But I am not attached to davcopy. Maybe there is another way to do this from the commandline? I do want to avoid powershell, because I need to provide a way for this to be done to certain users who don't have powershell.

I am thinking it could be done using some sort of dav service.

3
  • It is not working for me at all... Can anybody help.... Showing message in cmd : Syntax is not correct
    – user19021
    Commented Aug 20, 2013 at 7:12
  • Well, what is your commandline?
    – bgmCoder
    Commented Aug 20, 2013 at 13:34
  • I think he was missing /user:
    – grisha
    Commented Sep 23, 2014 at 13:39

4 Answers 4

13

Believe it or not, you can use Windows net use to map a sharepoint library to a drive letter! Then you can use plain old copy or xcopy or whatever.

net use r: https://some.portal.org/documents [password] user:domainName\[username]
copy c:\somefile.txt r:\somefile.txt

Here is where I found that answer. I've done this, and it works like a charm. You can even specify whatever credentials you like, too.

4
  • This is also the equivalent of using Windows Explorer and Map Network Drive R:\.
    – Russell
    Commented Aug 10, 2012 at 4:33
  • Yes, that's true, but the ideas was to do this from the commandline.
    – bgmCoder
    Commented Aug 10, 2012 at 13:37
  • Yep just in case :)
    – Russell
    Commented Aug 11, 2012 at 11:37
  • 1
    I don't think this works with Sharepoint Online now.
    – bgmCoder
    Commented Jun 1, 2020 at 15:26
1

you can also just call the DavWWWRoot as well.

so your url to your library is something like http://sharepoint/Site/SubSite/Library

your copy command would be copy somefile.txt \\sharepoint\DavWWWRoot\Site\SubSite\Library

Should work like a charm.

Edit. You will have to have at least one active File Explorer Connection to somewhere for this to work.

3
  • Welcome to the StackExchange community! This sounds like a good answer, do you know of any documentation to support it? I could see that being very useful to other people who come across this question.
    – thanby
    Commented Jan 3, 2014 at 17:33
  • I tried just what you did, and got the response The system cannot find the path specified. Maybe this only works on the server? How can my computer know that \\sharepoint is a web address and NOT a network computer?
    – bgmCoder
    Commented Jan 4, 2014 at 1:47
  • I tried it on the server and the response was 1 file(s) copied - so something happened! But I can't find the file anywhere.... I don't know what it did do.
    – bgmCoder
    Commented Jan 4, 2014 at 1:51
0

You may want to check out Sync FileSystem and SharePoint List on codeplex

4
  • Thanks, but that's not quite what I had in mind.
    – bgmCoder
    Commented Aug 10, 2012 at 3:10
  • @ashis-patel please add a good summary of your answer and then link. "link only answers" is of less use for our site, since links tend to die. Commented Aug 20, 2013 at 8:37
  • Yes, that makes sense. I will keep that in mind. Commented Aug 21, 2013 at 15:56
  • Case in point: Shutting down CodePlex - Brian Harry's Blog
    – njames
    Commented Sep 15, 2022 at 3:57
0

REM For example the following Batch file copies files to SharePoint.
REM Create a drive letter that maps to a SharePoint destination folder with NET USE. NET USE http://sharepoint REM Change to the source folder C: CD \SourceFolder REM Copy the files REM where C:\SourceFolder is the source folder REM and S:\destinationFolder is destination on SharePoint. COPY SourceFiles.* "S:\destinationFolder"

Not the answer you're looking for? Browse other questions tagged or ask your own question.