Skip to content

Instantly share code, notes, and snippets.

@heartnn
Forked from corona6/README.md
Created March 19, 2020 07:29
Show Gist options
  • Save heartnn/26721dbfde6d14e6557333d522b9b35c to your computer and use it in GitHub Desktop.
Save heartnn/26721dbfde6d14e6557333d522b9b35c to your computer and use it in GitHub Desktop.
delete unused resources https://joplinapp.org/
#
# Only can use for local file system synchronisation.
#
# Usage:
# $ ruby joplin_clean_up_resources.rb /path/to/synchronise/directory
#
path = ARGV[0].chomp("/")
resources = `ls #{path}/.resource`
resources.split.each do |resource|
next unless `grep -lr #{resource} #{path} | xargs grep -E "type_: 1\$" | wc -l`.chomp.to_i == 0
`rm -f #{path}/#{resource}.md`
`rm -f #{path}/.resource/#{resource}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment