I'm trying to get the list of files in a particular directory and count the number of files in the directory. I always get the following error:
WindowsError: [Error 3] The system cannot find the path specified: '/client_side/*.*'
My code is:
print len([name for name in os.listdir('/client_side/') if os.path.isfile(name)])
I followed the code example given here.
I am running the Python script on Pyscripter and the directory /client_side/ do exists. My python code is in the root folder and has a sub-folder called "client_side". Can someone help me out on this?
If you just want to see all the files in the directory where your script is located, you can use
os.path.dirname(sys.argv[0])
. This will give the path of the directory where your script is.Then, with
fnmatch
function you can obtain the list of files in that directory with a name and/or extension specified in thefilename
variable.I hope this helps.
You can do just
without slashes.