-
-
Save heartnn/26721dbfde6d14e6557333d522b9b35c to your computer and use it in GitHub Desktop.
delete unused resources https://joplinapp.org/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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