I thought of perhaps an easier way to fix your problem using AppleScript.There 
is a trick to get the relative path in AppleScript even in the linked file is 
broken. Here is a script that you could use to fix the links. Run  it from 
Script Editor.

property oldPathPrefix : "../../../../../../Volumes/GoogleDrive/"
property newPathPrefix : "../../GoogleDrive-USERNAME/"

tell document 1 of application "BibDesk"
        set theBibFile to its file
        set theIndex to 1 + (length of oldPathPrefix)
        set thePubs to its selection
        repeat with aPub in thePubs
                set thePub to contents of thePub
                if (count of linked files of thePub) > 0 and linked file 1 of 
thePub is missing value then
                        try
                                set relPath to export using text 
"<[email protected][email protected]/>" for 
{thePub}
                                if relPath starts with oldPathPrefix then
                                        set relPath to newPathPrefix & (text 
theIndex thru end of relPath)
                                        set theFile to resolve relPath relative 
to theBibFile
                                        set theFile to theFile as alias
                                        tell thePub
                                                remove linked file 1
                                                add theFile
                                        end tell
                                end if
                        end try
                end if
        end repeat
end tell


Of course you should replace the correct new path prefix (i.e. fill in 
USERNAME). The script works on the selected publications (from the main table). 
I would suggest to try it first on a single selected item, to see it works 
correctly. I have not tried out the script, as I don’t havenything to try it on.

Christiaan

> On 8 Feb 2023, at 00:09, Christiaan Hofman <[email protected]> wrote:
> 
> 
> 
>> On 7 Feb 2023, at 21:52, Laurel MacKenzie <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> I have Bibdesk auto-file my PDFs in a folder on a mounted Google Drive 
>> volume, so that I can access them from anywhere. Without warning, Google 
>> Drive has changed the way it mounts on a Mac, breaking all my file links.
>> 
>> Previously, files were saved at the following path:
>> ../../../../../../Volumes/GoogleDrive/My Drive/Books &amp; 
>> papers/FILENAME.pdf
>> (This is based on my decoding the bdsk-file-N field of entries added before 
>> the migration)
>> 
>> I've changed the autofile location in Bibdesk preferences so that 
>> newly-added PDFs go to the right place. Now, files are saved at this path:
>> ../../GoogleDrive-USERNAME/My Drive/Books &amp; papers/FILENAME.pdf
>> (This is based on my decoding the bdsk-file-N field of entries added after 
>> the migration)
>> 
>> But the 3000 PDFs I added before Google Drive migrated itself are all 
>> showing up as broken links in Bibdesk. Is there any way to fix them?
>> 
>> Thanks,
>> Laurel
>> 
_______________________________________________
Bibdesk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-users

Reply via email to