I currently have a folder with a python file sys.py.
In the same folder, I have a folder called "fsys", for file system, and I need to check what items are in the fsys folder.
My questions
I. How do I see what's in the folder and print it on screen?
II. How would I see how much capacity everything in the folder takes up and print it on the screen?
Thanks!
Edit: III. How would I make the list of directories perhaps blue?
My code is below:
usrn = "user"
cli = "konix>"
st = 1
vs = "Konix One 0.01"
# - System Declarations -
import os
from os import listdir
from os.path import isfile, join
# - Title Declaration -
print "- K O N I X -"
print ""
print "- Konix One 0.01 -"
print ""
# - Command Reading - #
while st == 1:
ucmd = raw_input(cli)
cmd = ucmd.partition(' ')[0]
if cmd == "print" or cmd == "pt":
print ucmd.partition(' ')[2]
if cmd == "version" or cmd == "vs":
print vs
if cmd == "tedit" or cmd == "td":
if ucmd.partition(' ')[2] == "-h" or ucmd.partition(' ')[2] == "-help":
print "Konix Tedit v1.2 Help"
print "To open tedit, type in tedit -u in the console"
print "You should see that your text pointer also has @tedit"
print "To use tedit, first type in text normally."
print "When you are done writing text, create two spaces, put a period, and press enter again."
print "It will show you what you wrote, and you have the option to save or not."
print "Good luck using tedit!"
elif ucmd.partition(' ')[2] == "-u":
input_list = []
while True:
input_str = raw_input("konix@tedit>")
if input_str == "." and input_list[-1] == "":
break
else:
input_list.append(input_str)
for line in input_list:
print line
save = raw_input("Would you like to save this text to your file? [Y/N]: ")
if save == "Y" or save == "y":
name = raw_input("Please enter a name for this file (with .txt at the end): ")
fsys = "fsys/"
fsys += name
filestring = '\n'.join(input_list)
with open(fsys, 'w') as f:
f.write(filestring)
elif save != "N" or save != "n":
print "Not saving"
if cmd == "list" or cmd == "ls":
onlyfiles = [ f for f in listdir("fsys") if isfile(join("fsys",f)) ]
print os.path.join(root, file)
if cmd == "kill" or cmd == "kl":
print "Killing Konix - Farewell!"
st = 0