I have implemented a solution in AutoHotkey see documentation here
It is based on @GWD idea (see comments below) to generate a temporary excel file with the formula CELL("filename") at each sync locations to extract this mapping information to a text file that is then later parsed to do the reverse mapping from local file to SharePoint url.
Here is the code part extracted from the linked post:
SharePoint_UpdateSync(){
; SharePoint_UpdateSync()
; Update SPSync.ini file creating temporary Excel files in each sync directory
sIniFile := SharePoint_GetSyncIniFile()
FileRead, IniContent, %sIniFile%
oExcel := ComObjCreate("Excel.Application")
oExcel.Visible := False ; DBG
oExcel.DisplayAlerts := false
Loop, Reg, HKEY_CURRENT_USER\Software\SyncEngines\Providers\OneDrive, K
{
RegRead MountPoint, HKEY_CURRENT_USER\Software\SyncEngines\Providers\OneDrive\%A_LoopRegName%, MountPoint
MountPoint := StrReplace(MountPoint,"\\","\")
; Exclude Personal OneDrive
If InStr(MountPoint,"\OneDrive -")
Continue
FoundPos := InStr(MountPoint, "\" , , -1)
sOneDriveDir = SubStr(MountPoint,1,FoundPos-1)
If InStr(IniContent,MountPoint . A_Tab) ; already mapped
Continue
xlFile := MountPoint . "\SPsync.xlsx"
; Create Excel file under MountPoint
xlWorkbook := oExcel.Workbooks.Add ;add a new workbook
oSheet := oExcel.ActiveSheet
oSheet.Range("A1").Formula := "=CELL(""filename"")" ; escape quotes
oSheet.Range("A1").Dirty
; Save Workbook https://learn.microsoft.com/en-us/office/vba/api/excel.workbook.saveas
Try ; sometimes return error "Enable to get the SaveAs property" but still work
xlWorkbook.SaveAs(xlFile,xlWorkbookDefault := 51)
; Calculate Formula
oSheet.Calculate
; Get value
UrlNamespace := oSheet.Range("A1").Value
;Find last /
FoundPos:=InStr(UrlNamespace,"/",,0)
UrlNamespace := SubStr(UrlNamespace,1,FoundPos-1)
xlWorkbook.Close(False)
; Delete temp file
FileDelete, %xlFile%
If (UrlNamespace = "") {
sTrayTip := "Error in getting url path for synced location '" . MountPoint . "'!"
TrayTip Check Mapping in SPsync.ini! , %sTrayTip%,,0x2
Run "%sIniFile%"
}
FileAppend, %MountPoint%%A_Tab%%UrlNamespace%`n, %sIniFile%
} ; end Loop