Quantcast
Channel: skydrivesimpleviewer Discussions Rss Feed
Viewing all articles
Browse latest Browse all 20

New Post: Q: Uploading/downloading content programatically?

$
0
0

Thans for your program. I'm using it for Microsoft Office WebApps. I have set file extension association to my script for Office xls;xlsx;doc;docx. Office's file is uploaded to SkyDrive "My documents" folder in my account and then opened in WebApps Office. After close its saved back to original location.

SkyDrive.cmd

:: Usage    : SkyDrive.cmd "c:\data\file.xls"
:: Usage    : use Types ( http://izt.name/apps/types/ ) toset Explorer ContextMenu "C:\Program Files (x86)\SkyDrive\SkyDrive.cmd""%1"for doc;docx;xls;xlsx
:: Tested on: Windows 7 EN x64
:: ToDo     : renaming xls<-->xlsx ; doc<-->docx
::main
setlocal 
setlocal ENABLEDELAYEDEXPANSION
:: ---------------- CONFIG-BEGIN ----------------set SkyDriveLogin=login@domain.comset SkyDrivePassword=passwordset SkyDriveFolder=My Documentsset SkyDriveShare=O:set SkyDriveDumpUrls=C:\Program Files (x86)\SkyDrive\DumpUrls.exe
:: ---------------- CONFIG-END ----------------set file=%1set filename=%~nx1set filepath=%~dp1
:: replace spaces with %20set SkyDriveFolderNoSpace=!SkyDriveFolder: =%%20!
:: Get SkyDrive CIDfor /f "tokens=*" %%a in ('"%SkyDriveDumpUrls%" %SkyDriveLogin% %SkyDrivePassword%') do set cid=%%aset cid=%cid:https://dvpdwm.docs.live.net/=%set cid=!cid:/%SkyDriveFolderNoSpace%=!
:: Check if"net use" exists andusing valid CIDifNOT exist %SkyDriveShare%\ (goto :mount
) else (for /f "tokens=1,2,*" %%a in ('net use %SkyDriveShare% ^| find "Remote name"') do echo %%c | findstr /l /i /c:"%cid%"ifNOT !errorlevel!==0 goto :unmount
)goto :openfile
:unmount
net use %SkyDriveShare% /delete /Y
:mount
net use %SkyDriveShare% https://dvpdwm.docs.live.net/%cid%/%SkyDriveFolderNoSpace% /user:%SkyDriveLogin% %SkyDrivePassword%
:openfileif {"%filename%"}=={""} (
  :: if no arguments, open foldercall"C:\Program Files (x86)\Internet Explorer\iexplore.exe" https://cid-%cid%.office.live.com/browse.aspx/%SkyDriveFolder%
) else (
  :: copy file to SkyDrive and open in OfficeWebAppscall del /Q "%SkyDriveShare%\%filename%"?call copy %1 "%SkyDriveShare%\%filename%"call"C:\Program Files (x86)\Internet Explorer\iexplore.exe" https://cid-%cid%.office.live.com/edit.aspx/%SkyDriveFolder%/%filename%
  :: wait 10sec for correct saving of Office file back to SkyDrive
  ping -n 10 127.0.0.1call copy /Y "%SkyDriveShare%\%filename%"? "%filepath%*.*"call del /Q "%SkyDriveShare%\%filename%"?
)goto :EOFexit

Viewing all articles
Browse latest Browse all 20

Trending Articles