Thi*_*y_S 2 windows powershell dropbox
Python中存在同样的问题:如何在Python中以编程方式获取Dropbox文件夹位置?或者在这里用于OSX:如何获取当前登录的Dropbox文件夹的位置
在Powershell中也是如此.我需要DropBox的路径来复制文件(构建软件然后将其复制到dropbox以与团队共享).
此Dropbox帮助页面告诉我们该信息的存储位置,即用户AppData中的json文件:https://www.dropbox.com/help/4584
function GetDropBoxPathFromInfoJson
{
$DropboxPath = Get-Content "$ENV:LOCALAPPDATA\Dropbox\info.json" -ErrorAction Stop | ConvertFrom-Json | % 'personal' | % 'path'
return $DropboxPath
}
Run Code Online (Sandbox Code Playgroud)
上面的行取自:https://www.powershellgallery.com/packages/Spizzi.Profile/1.0.0/Content/Functions%5CProfile%5CInstall-ProfileEnvironment.ps1 请注意,它不会检查您是否有Dropbox企业帐户,或两者兼有.它只是使用个人的.
然后,您可以使用此基本Dropbox文件夹来构建最终路径,例如:
$targetPath = Join-Path -Path (GetDropBoxPathFromInfoJson) -ChildPath 'RootDropboxFolder\Subfolder1\Subfolder2'
if (-not (Test-Path -Path $targetPath)) { throw "Path '$targetPath' not found!" }
Run Code Online (Sandbox Code Playgroud)
-
另一种方法是使用host.db文件,如本页所示:http://bradinscoe.tumblr.com/post/75819881755/get-dropbox-path-in-powershell
$base64path = gc $env:appdata\Dropbox\host.db | select -index 1 # -index 1 is the 2nd line in the file
$dropboxPath = [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($base64path)) # convert from base64 to ascii
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1304 次 |
| 最近记录: |