Does it do the same thing as this:
cd ~/.config/joplin-desktop for i in sqlite3 database.sqlite "select resource_id from note_resources where is_associated = 0" do rm resources/$i* done sqlite3 database.sqlite "delete from note_resources where is_associated = 0"
sqlite3 database.sqlite "select resource_id from note_resources where is_associated = 0"
which I found in this discussion: