Saturday, March 10, 2012

SharePoint - Script to copy a files to SharePoint Library


Recently I was asked to automate a file copy from windows (UNC) into a SharePoint directory.  There are limitations with this especially with windows 7 and Server 2008 but luckily my requirement was from a Windows 2003 server to SharePoint 2010. You need to make sure you can view the "Explorer View" for this to work.


I used this simple DOS script, utilising  PUSHD (connects a the last free network drive) and POPD (release network drive).


rem $echo off
rem ************
set REPORT="d:\Sharepointcopy\InsiteSharepoint2010.log"
echo %date% %time% >> %REPORT%
pushd "\\contoso.com\Documents" >> %REPORT%
copy d:\*.xml /Y z:\ >> %REPORT%
popd 
echo %date% %time% >> %REPORT%
echo *Finished*>> %REPORT%



No comments:

Post a Comment