Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] One Drive Local Paths #134

Open
dougransom opened this issue Oct 30, 2020 · 3 comments
Open

[FEATURE] One Drive Local Paths #134

dougransom opened this issue Oct 30, 2020 · 3 comments

Comments

@dougransom
Copy link

I'm always frustrated when I edit a file in a OneDrive Library on mylocal file system, and I would like to share that file with another user who has that same Library synced to their local file system.

Right now we can't. If we use the OneDrive share feature, the other user ends up opening the file in their web browser instead of their desktop app. It sucks. So we usually copy the folder name with path copy or explorer like C:\Users\Doug\Org Name\operations - Documents and then type the file name in like "weekly meal plan.docx" into an instant message.

The recipient then manually navigates (since their folder will always have a different name than the sender for the same library ) to C:\Users\Bill\Org Name\operations - Documents and then look for and click on "weekly meal plan.docx".

Describe the solution you'd like

A conext Menu "Path Copy/Copy OneDrive Path" would put these two urls in the clipboard (properly url encoded):
pathcopyod://%OneDriveForBusiness%/Org Name/operations - Documents/weekly meal plan.docx"
and pathcopyod://%OneDriveForBusiness%/Org Name/operations - Documents/

That URL, send to anyone else who has the library synchronized to their computer and pathcopy installed, when they click on it, will open the the file and folder on their local computer respectively.

This does mean a URL scheme must be packed with PathCopy.

The OneDrive Libraries can be resolved by looking at Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\OneDrive\Accounts\Business1\ScopeIdToMountPointPathCache

It may be the ScopeID Value Name is the same for all users who are syncing the library, in which case the URL might instead be more simply

pathcopy:[ScopeID]/weekly meal plan.docx which we could exchange with each other using telegram or email etc.

@jonnywright
Copy link

jonnywright commented Apr 26, 2021

I have been trying to find a solution to this and thought I found one but I can't get it to work - this could well be down to my regex skills though (or lack of).
I created a custom command which uses regex to replace the second level of the path which (in my case) is my username. I would then replace the second level of the path with the environment variable %username% to make it work on anyone elses machine. Below is the regex I'm trying. It passes in regex101 but errors in PCC with Invalid regular expression

(?<=\w\:\\(\w|\d|\s|\.)*\\)(\w|\.|\d|\s)+

@firewiremb
Copy link

I want to agree with dougransom. PathCopy has unfortunately not been as useful for me since OneDrive was introduced in my company as it was in previous years.
In my opinion, a solution to this problem is urgently needed. Unfortunately, my programming skills are not sufficient to be able to contribute anything here.

@apotenza92
Copy link

I've dealth with a somewhat similar issue when creating an Excel VBA macro. I'm not sure who this might help but here's a code I found and slightly modified that turns sharepoint URLs into local paths. I suspect using something like this as a starting point (the way it calls the registry) could help with with this issue.

' Set default return
GetLocalFile = wb.FullName
Const HKEY_CURRENT_USER = &H80000001
Dim strValue As String
Dim objReg As Object: Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
Dim strRegPath As String: strRegPath = "Software\SyncEngines\Providers\OneDrive\"
Dim arrSubKeys() As Variant
objReg.EnumKey HKEY_CURRENT_USER, strRegPath, arrSubKeys

Dim varKey As Variant
For Each varKey In arrSubKeys
    ' check if this key has a value named "UrlNamespace", and save the value to strValue
    objReg.getStringValue HKEY_CURRENT_USER, strRegPath & varKey, "UrlNamespace", strValue

    ' If the namespace is in FullName, then we know we have a URL and need to get the path on disk
    If InStr(wb.FullName, strValue) > 0 Then
        Dim strTemp As String
        Dim strCID As String
        Dim strMountpoint As String
    
        ' Get the mount point for OneDrive
        objReg.getStringValue HKEY_CURRENT_USER, strRegPath & varKey, "MountPoint", strMountpoint
    
        ' Get the CID
        objReg.getStringValue HKEY_CURRENT_USER, strRegPath & varKey, "CID", strCID
    
        ' strip off the namespace and CID
        strTemp = Right(wb.FullName, Len(wb.FullName) - Len(strValue))
    
        ' replace all forward slashes with backslashes
        GetLocalFile = strMountpoint & "\" & Replace(strTemp, "/", "\")
        Exit Function
    End If
Next

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants