Batch Script - How do you make it upload to a 2003 sharepoint site?

Posted on 2011-04-28
Last Modified: 2012-05-11

Is is possible to use a batch script to upload pdf files to a sharepoint 2003 site?

I have a batch script i use already that generates some reports from an unshared network drive. But in the middle of my script i have it pause so that i can then upload a few hundred reports to a sharepoint site manually, before it deletes these reports for the next business day.

I want to make my script smarter by having it upload the reports for me to the sharepoint site without any user interaction. Can this be done?

Couple of points that need to be in place if this is possible:

1. Batch script must be able to run from any computer on the network as the reports are on a unshared network drive. Ive achieved this by using the "pushd [path]" and "popd" commands in my present script. So if a external freeware program is needed to do this, i have seen some example where you can have the script go out and run the program from an unshared network drive. Just dont know what software does this.

2. I will need some sort of % of completion for the upload of the reports, i have seen some batch scripts do this but personally dont know how to do it. Where you will see the % go from 1 to 100 on how much is completed. Need something like this so i will know if the process has stalled or failed etc.

3. As a bonus, Would be nice to know if after the script uploads the reports it displays to the screen and tells me how many reports have been uploaded to confirm the correct number of reports went up. As these reports then need to be deleted for the next business day. So my currrent script deletes them after i upload them. So as a failsafe if the script can tell me how many reports have been uploaded before i push enter to have the script delete them that would be great.

And thats about it. I do have domain admin rights to the network, so permissions should not be a problem.

I know that some vbs scripts can be used with batch scripts. But i would prefer not to go this route and make everything work in the batch script.

Appreciate the help.

Question by:ampike
    LVL 14

    Expert Comment

    I  understand your simple request .

    Let us work on a simple configuration first.

    You can map a drive to the document library that you want as destination. , read more here

    then using the batch file , you can copy to that location.

    Best of luck.


    Author Comment

    Hi George,

    This doesnt quite help me as this link is showing how to map a sharepoint site from within Windows Explorer using Tools \ Map Network drive.

    What i want to do is have a "batch script" access my sharepoint site and from there upload my reports to the site all through the batch script. The end user running the script should not need to map any drive. The batch script should do all of this for them if need be. I know the "pushd" and "popd" commands are capable with assisting with this of assigning temporary "mapped" drive but can't figure out how to make this work with what i want to do. As these commands use the next available mapped drive on the users computer, so the mapped drive will be different for everyone in my team. So i cant use this method.

    Please advise.

    LVL 14

    Expert Comment

    this will map the library location to a drive letter like S: or Q: etc.

    then you can use your script to connect to that drive letter


    Author Comment

    Thanks George,

    Yes i understand that this solution that you found will map the location to a lettered drive. But this is not what i am asking for. As said previously i need something that will map or point to this location. But the user running the script must not be the one to map it.

    As my team have various drives mapped, so if i go this route i must tell my team to make sure their S drive or whatever is available and needs to be mapped to the location i specifiy.

    While i do appreciate your effort, this is not what i am requesting. The script needs to run without any user interaction.

    I will research more on this for point 1 as what you have provided me with is not helpful.

    Are you perhaps able to help me with points 2 and 3?

    LVL 14

    Expert Comment

    mapping the drive is simply with regualr map commmands

    net use q:  "http://spServer/sites/department/MyDept/Shared Documents"

    Q: becomes a drive on your machine

    Questions 2 and 3  not doable with bat commands.


    Author Comment

    Hi George,

    I understand quite clearly on how to map a drive and how to do this in my batch script. But you are missing a very important point that I keep trying to explain to you. And this is that there must "NOT" be any user interaction.

    I could very well use the R: mapping by doing as you say, net use r: "http://server/sites/deparment/" but with this i will need to instruct my team to keep the R drive available to use with my script (which they may be using for something else already). So using the command "net use" will not work in my situation. I need the batch script to automatically locate the next available drive letter, so that my team does not have to worry about which drive letter to keep available.

    Please see below as i have figured out this part on my own, which does exactly what i want by the script looking for the next available letter mapping to map off of the persons system. And then remove it once done. Therefore there is no need to instruct my team on what letter mapping to keep available to use the batch script.


    @echo off

    :: This is creating a mapped drive using the next "available" letter mapping on the users computer, mapping to the sharepoint destination. Without the user having to do anything.

    pushd "\\serverx\sites\Dept\SystemReports\TestFolder"

    :: This is copying all PDF reports from the source to the destination sharepoint folder.

    copy "\\ReportServer\generated\testfolder\*.pdf"

    :: This is removing the mapping created above with the pushd command.



    Question 2 regarding the progress of the transfer is doable with batch scripts. I am 500% sure on this fact as i have seen it in action before. I just cant remember where as if i did i wouldnt need to ask this question.

    With question 3 i wouldnt see why this is not possible. You said question 2 is not doable when i know it is, so I am very curious if this is really workable.

    Thank you for your assitance but i think i will just wait for another expert who specializes in Batch scripting to reply.

    Kind Regards
    LVL 1

    Accepted Solution

    Hi ampike,

    Yes, doing a completion bar sort of thing in a batch script is possible.

    See if these 2 sites help you with your question.

    Let me know if you need help implementing these in to your batch.

    LVL 43

    Assisted Solution

    by:Steve Knight
    Ive got some on my scripts library here too ... Most rely on a technique found here on EE using set /p command to be able to echo some text to the screen without a carriage return ... You can combine that with changing colours; windows size etc. To make some reasonable progress indicators etc.... However you are updating it with every movement needed and therefore to do it as the copy progresses logically youd do it as a loop using a for command and then for each item update the progress bar and copy files etc...

    Not typing any code out on here but have a look at suggestions above to see what you are after and can help bolt things together if needed.


    Author Comment

    Excellent dragon and Nobu. Thanks for this.

    I will give it a go and advise if i run in to any hiccups.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
    Recently, an awarded photographer, Selina De Maeyer (, completed a photo shoot of a beautiful event ( in An…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now