Search for content across multiple mindmaps.
I am an avid user of Xmind. I probably have more than 500 mindmaps that I created for my job. I use mindmaps to help me remember the context of the job I am bust with. My problem? Remembering in which mindmap I covered a specific topic of my job becomes an issue. Does Say I have a folder structure with 500 Xmind mindmaps. Is it possible to search for a topic across these folders to find the topic I am looking for?
-
This can be easily done by running a Python script that will search all the files in your current folder and subfolders and return the files containing the sentence and the number of times it was found. You can ask ChatGPT for steps on how to run this file:
Command: python search.py "Replace with your text"
File:
import osimport codecsimport ioimport sys
def search_for_keyword_in_file(file_path, keyword):try:with io.open(file_path, encoding='utf-8', errors='ignore') as f:FileFound = Falsecount = 0for line in f:if keyword in line:FileFound = Truecount += line.count(keyword)if FileFound:print(f'{file_path} {count}')
except (OSError, UnicodeDecodeError):#print(f"Error reading file: {file_path}")x=1
def search_files_for_keyword(root_folder, keyword):for root, _, files in os.walk(root_folder):for file in files:file_path = os.path.join(root, file)search_for_keyword_in_file(file_path, keyword)
if __name__ == '__main__':if len(sys.argv) != 2:print("Usage: python search.py <keyword>")sys.exit(1)
current_folder = os.getcwd()keyword_to_search = sys.argv[1]search_files_for_keyword(current_folder, keyword_to_search)
Please sign in to leave a comment.
Comments
3 comments