I am working on a script to get my present workind directory, concatenate it to "cd" and write that string to a file. However whenever I try to specify the path I get the following error:
FileNotFoundError: [Errno 2] No such file or directory: 'home/cameron/projects/personal/new_window/last_directory.txt'
import os
import sys
from pathlib import Path
# Get working directory and transform into command string
stream = os.popen('pwd')
output = "cd " + stream.readline()
path = 'home/cameron/projects/personal/new_window/last_directory.txt'
# Open and write command to file
file = open(path,'w')
file.write(output)
file.close()
# Print status
print("Current Directory written:")
print(stream)
Any help would be much appreciated. I'd like to write this command so that when I'm deep in a file tree I can save it's location in the case I need to open another window. Thanks!