Skip to content

Instantly share code, notes, and snippets.

@Flecart
Created July 14, 2023 21:23
Show Gist options
  • Save Flecart/af2494c776e73492440dc6329ae3c3ba to your computer and use it in GitHub Desktop.
Save Flecart/af2494c776e73492440dc6329ae3c3ba to your computer and use it in GitHub Desktop.
I used this script to add some tags on my obsidian vault, it's useful if you just imported stuff from notion-like websited, and you are trying to migrate to obsidian
#diary #pensieri
import os
def add_tag(file_name):
with open(file_name, 'r+') as f:
content = f.read()
f.seek(0, 0)
# if a string is in the file then print helloworld
if "Tipologia: Diario" in content:
f.write("#diary #pensieri\n" + content)
else:
f.write("#pensieri\n" + content)
def main():
# transverse currect directory
for root, dirs, files in os.walk("."):
for file in files:
print(file)
add_tag(file)
break;
# create a file
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment