directory « List « Python Data Type Q&A

Home
Python Data Type Q&A
1.array
2.date
3.dictionary
4.Format
5.integer
6.List
7.numpy
8.regex
9.string
10.tuple
Python Data Type Q&A » List » directory 

1. Directory listing in Python    stackoverflow.com

How do I get a list of all files (and directories) in a given directory in Python?

2. How to list only top level directories in Python?    stackoverflow.com

I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders. Let's see if an example helps. In ...

3. Directory Walker for Python    stackoverflow.com

I am currently using the directory walker from Here

import os
class DirectoryWalker:
# a forward iterator that traverses a directory tree

def __init__(self, directory):
    self.stack = [directory]
   ...

4. Getting a list of all subdirectories in the current directory    stackoverflow.com

Is there a way to return a list of all the subdirectories in the current directory in python? I know you can do this with files, but I need to get the ...

5. How can I create a list of files in the current directory and its subdirectories with a given extension?    stackoverflow.com

I'm trying to generate a text file that has a list of all files in the current directory and all of its sub-directories with the extension ".asp". What would be the ...

6. python get a filtered list of files in directory    stackoverflow.com

I am trying to get a list of files in a directory using python, but I do not want a list of ALL the files. What I essentially want is the ability ...

7. How to list directory hierarchy in PyGTK treeview widget?    stackoverflow.com

I am trying to generate a hierarchical directory listing in pyGTK. Currently, I have this following directory tree:

/root
    folderA
        - subdirA
  ...

8. List Directories and get the name of the Directory    stackoverflow.com

I am trying to get the code to list all the directories in a folder, change directory into that folder and get the name of the current folder. The code I ...

9. In Python, how to find all the files under a directory, including the files in subdirectories?    stackoverflow.com

Is there any built in functions to find all the files under a particular directory including files under subdirectories ? I have tried this code, but not working...may be the logic itself ...

10. using wild card when listing directories in python    stackoverflow.com

how can I use wild cars like '*' when getting a list of files inside a directory in Python? for example, I want something like:

os.listdir('foo/*bar*/*.txt') 
which would return a list ...

11. List classes in directory (Python)    stackoverflow.com

I'm developing a Python 2.6 package in which I would like to fetch a list of all classes in a certain directory (within the package) in order to then perform introspection ...

12. how to list all files of a directory in python    stackoverflow.com

how to list all files of a directory in python, and add it to a list?

13. Permanently add a directory to PYTHONPATH    stackoverflow.com

Whenever I use sys.path.append, the new directory will be added. However, once I close python, the list will revert to the previous (default?) values. How do I permanently add a directory ...

14. getting a list of files in a custom directory using glob()    stackoverflow.com

Im trying to write a program that renames files when a use input their own custom file directory. I'm at a very early part of it. And this is my first time ...

15. Directory Listing based on time    stackoverflow.com

How to list the files in a directory based on timestamp?

 os.listdir() 
lists in arbitrary order. Is there a build-in function to list based on timestamp? or by any order?

16. Is there a one-liner to list a directory two levels deep where the second level is an only-child, but not known?    stackoverflow.com

Suppose you have a directory structure like this:

A/
   B/
      a.1
      b.2
      c.3
I'm wondering if ...

17. Is there a way to efficiently yield every file in a directory containing millions of files?    stackoverflow.com

I'm aware of os.listdir, but as far as I can gather, that gets all the filenames in a directory into memory, and then returns the list. What I want, is a ...

18. Make multiple Directories based on a list in python    stackoverflow.com

Hi I would like to make multiple new dir's in a set root dir each one named based on a list of names e.g. List looks like this Folder_1 Folder_x Folder_y is there an easy way to ...

19. Python: Inputting files in a directory to a list    stackoverflow.com

I understand that with the glob or listdir modules you can get a list of all the files in a directory. However, I need to know how assign the output from ...

20. argv listing directory files    stackoverflow.com

this very simple code is driving me nuts.

import sys,string,socket  

maquina = sys.argv[1]
texto = string.join(sys.argv[2:], " ")
print '['+maquina+']' 
print '['+texto+']'

mysock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
if  maquina == '*':
   ...

21. Pythonic way to remove directories from a file listing    stackoverflow.com

I can think of easy ways to accomplish this, but what is the most pythonic way? I get a file listing for os.listdir, and some may be directories. ...

22. directory listing in python    stackoverflow.com

I am getting trouble with directory listing.Suppose, I have a directory with some subdirectory(named as a-z, 0-9, %, -).In each subdirectory, I have some related xml files. So, I have to read ...

23. List directories with a specified depth in Python    stackoverflow.com

I'm want a function to return a list with directories with a specified path and a fixed depth and soon realized there a few alternatives. I'm using os.walk quite a lot ...

24. How to refine list of directories to remove subdirectories of newly added directory    stackoverflow.com

I have a list of directories, eg:

direc_list = [r'C:\test', r'C:\test2\subdir']
I then want to add another directory to the list
new_direc = r'C:\test2'
How can I correctly remove any subdirectories of this new ...

25. Python can't list my directory    stackoverflow.com

I have this code in my Bottle app to list a directory full of files:

[Post(name[:-3]) for name in os.listdir("posts")]
On my local computer, it's fine. But on my server I ...

26. Create a tree-style directory listing in Python    stackoverflow.com

I am trying to list directories and files (recursivley) in a directory with python:

./rootdir
  ./file1.html
  ./subdir1
    ./file2.html
    ./file3.html
  ./subdir2
  ./file4.html
Now I ...

27. python: how to override SimpleHTTPServer to show timestamp in directory listing?    stackoverflow.com

I am using

 python -m SimpleHTTPServer
as a very simple web server for internal users to access data files on a test server. The default listing of SimpleHTTPServer is very simple. It ...

29. Trying to get a list of files from directories    python-forum.org

Trying to get a list of files from directories by mrCoffee Sun Oct 18, 2009 4:21 pm Hi guys, What I need is basically a list of all the files (with the full paths) so I can open each one up and parse through it. I also need all the subdirectory files as well. But I don't want it to ...

30. Get a list of specific files in a directory    python-forum.org

ooh, I need to know this too. Sorry hlynur, I'd normally refrain from posting non-helpful stuff like this but imagine my surprise when I join the forum and the top post is asking exactly what I need. Anyways, I'm beyond a python novice (having downloaded it only after the xkcd cartoon) but I really like what I've done so far with ...

31. How to get hold of access control data in directory listing?    python-forum.org

Code: Select all import os path = os.path.expanduser('~') + os.sep for f in os.listdir(path): if f[0] != '.': # exclude hidden Unix files s_r = s_w = s_x = ' ' ...

32. a little confused about directory listing    python-forum.org

import os, sys def convert2ppm(): print(working_dir) a=0 for file_name in os.listdir(working_dir): print file_name a=a+1 print a if __name__ == '__main__': working_dir=sys.argv[1] try: ...

33. List files in a web directory?    python-forum.org

Hi Is there a way in Python to list all the files in a specific directory on a website? I know how to use urllib.urlretrieve() to get an html file, but if I don't know the name of the file is it possible to list all the files using something like os.listdir() so that I can retrieve them using a loop? ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.