Is there a way to automatically remove invalid google drive shortcuts?

What is your rclone version (output from rclone version)

rclone v1.52.2-192-g8d5bc7f2-beta

Which OS you are using and how many bits (eg Windows 7, 64 bit)

  • os/arch: linux/amd64
  • go version: go1.14.4

Which cloud storage system are you using? (eg Google Drive)

Crypt remove over a shared google drive remote

What is the problem you are having with rclone?

I started experimenting with the google shortcut feature yesterday and took some inspiration from this post on how to add them to a crypt remote.

Then I ran some other commands that deleted the source files, but the shortcuts are still there.

If I try access these files from a mount or perform a ls on the folder with shortcut
The logs are showing these messages

ERROR : <redacted>/: Dir.Stat error: list: failed to resolve shortcut: googleapi: Error 404: File not found: 1SqtqIm1O3zm2o79UE3p2lrdXdEkXFewN., notFound

This makes perfect sense as the files are no longer there.

In the browser interface the invalid shortcuts are greyed out and have a remove shortcut button. So they can easily be removed there.

I guess I could parse the log and have a script remove the invalid shortcuts.
Do any better way exist to have rclone remove invalid shortcuts?
Would it be possible to either integrate this logic in some command or add a new command to have rclone auto remove invalid shortcuts from a specified remote and path?

Can you try this

v1.52.2-194-ge6fdc3a9-fix-drive-dangling-shortcut-beta on branch fix-drive-dangling-shortcut (uploaded in 15-30 mins)

That shows invalid shortcuts as empty files which you can delete.

Thank you for the quick response.
That fixed the bug in Rclone ls command fails on a directory that contains at least one invalid drive shortcut

And now I guess I can script something to listing the files with lsjson and look for "MimeType":"application/"

Would still be nice if there was somesort of command to have rclone autodelete them. But not super important.

Thank you once again for the quick response:)


I've merged this fix to master now which means it will be in the latest beta in 15-30 mins and released in v1.52.3 most likely

Yes that will work. BTW that isn't an official google mimetype - I made that one up!

You could also do an rclone lsf -R of the directory - rclone will write NOTICE level logs when it sees a dangling shortcut.

That would fit in the backend command framework if someone has the energy to write it!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.