I am using the python plugin for notepad ++ and need to be able to get a printout of all the files in a directory. Basically I need to run something like dir in command prompt.
Is there any way to do this?
So, here's how to put all the files in a directory and in all its sub-directories in a list, print out the list.
Note: How to 'walk' was found here:
concatenate the directory and file name
# Task: Get a printout of all the files in a directory.
import os
# The directory that we are interested in
myPath = "/users/george/documents/"
# All the file paths will be stored in this list
filesList= []
for path, subdirs, files in os.walk(myPath):
for name in files:
filesList.append(os.path.join(path, name))
for i in filesList:
print (str(i))
os.listdir('.')?dir, then you'll need to useos.staton each one and format the columns yourself—or, of course, you can usesubprocess.check_outputto just run the command prompt'sdircommand.