Zettelkasten Forum


Script to print all tags from .txt files (run from archive directory)

2»

Comments

  • Counting occurrences instead of notes?

  • @toddgrotenhuis said:
    I've been trying this:

    find . -type f -print0 -not -name '.*' | xargs -0 grep -EIoh '(?:^|\s)#[A-Za-z0-9_ÄÖÜäöüß-]+' |sort | uniq -c | sort -rn > "Tag List.txt"

    Remove the 0-9. This will eliminate all instances where you have a # symbol followed by a number as in the numbered lists you have created. Be sure and not start a tag you care about with a number.

    If you had a space between the # and the number in your numbered lists, you wouldn't have this problem.

    try
    find . -type f -print0 -not -name '.*' | xargs -0 grep -EIoh '(?:^|\s)#[A-Za-z_ÄÖÜäöüß\-]+' |sort | uniq -c | sort -rn > "Tag List.txt"

    Will Simpson
    I'm a Zettelnant.
    Research: Rationalism, Zen, Non-fiction Creative Writing
    kestrelcreek.com

  • Ok, one more piece of advice, please? I'm getting some with a preceding space and some without, and not sure why?

    41 #inbox
    3 #inbox

  • I'm not sure what you mean by "a preceding space and some without," in your specific example.
    I get better formating of the tag list if I use the following. I'm excluding file with a ★ which includes "★ Tag Cloud.md" else the macro counting all the tags in the tag cloud and adding it to the total.

    cd /Users/will/Dropbox/zettelkasten/ egrep --exclude="★*.*" -ohsr "(?:^|\s)#[A-Za-z0-9_ÄÖÜäöüß\-]+" -- * | sed -e 's/[[:space:]]#/#/' | sed /^[^#]/d | sort | uniq -c | sort -t# -k2 > "★ Tag Cloud.md"

    Will Simpson
    I'm a Zettelnant.
    Research: Rationalism, Zen, Non-fiction Creative Writing
    kestrelcreek.com

Sign In or Register to comment.