You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now the tool has a hardcoded feature where the saving of audio and history feature makes two folders in the location where the tool is present, but if we open the tool and its not in a directory then it doesn't make the directories.
Task to do:
Use os module's feature of getting the working directory's path and use that to make directories.
Test it by copying the script out of folder and directly open it in terminal and see if it makes the directories of Audios and history.
The text was updated successfully, but these errors were encountered:
- def save_to_history(text):+ def save_to_history(text, dir_path=None):
# Get current date
current_date = datetime.now().strftime("%Y-%m-%d")
# Create history folder if it doesn't exist
- history_folder = "history"+ history_folder = dir_path or "history"
os.makedirs(history_folder, exist_ok=True)
# Create subfolder for current date if it doesn't exist
date_folder = os.path.join(history_folder, current_date)
os.makedirs(date_folder, exist_ok=True)
# Create markdown file for current date if it doesn't exist
markdown_file = os.path.join(date_folder, "history.md")
# Write text to markdown file with a timestamp
with open(markdown_file, "a") as file:
file.write(f"\n\n---\n\n{datetime.now().strftime('%H:%M:%S')}\n{text}\n")
Thanks for the suggestion! To ensure directories are created correctly regardless of where the script is run, we should use os.getcwd() to get the current working directory. Here's an example:
Right now the tool has a hardcoded feature where the saving of
audio
andhistory
feature makes two folders in the location where the tool is present, but if we open the tool and its not in a directory then it doesn't make the directories.Task to do:
os
module's feature of getting the working directory's path and use that to make directories.Audios
andhistory
.The text was updated successfully, but these errors were encountered: