Questions tagged [directory-walk]
26 questions
36
votes
4 answers
Quicker to os.walk or glob?
I'm messing around with file lookups in python on a large hard disk. I've been looking at os.walk and glob. I usually use os.walk as I find it much neater and seems to be quicker (for usual size directories).
Has anyone got any experience with…
![](../../users/profiles/734463.webp)
joedborg
- 15,097
- 30
- 72
- 112
30
votes
11 answers
What is the Python way to walk a directory tree?
I feel that assigning files, and folders and doing the += [item] part is a bit hackish. Any suggestions? I'm using Python 3.2
from os import *
from os.path import *
def dir_contents(path):
contents = listdir(path)
files = []
folders =…
![](../../users/profiles/647496.webp)
Mike
- 1,484
- 1
- 11
- 12
22
votes
5 answers
Hadoop MapReduce provide nested directories as job input
I'm working on a job that processes a nested directory structure, containing files on multiple levels:
one/
├── three/
│ └── four/
│ ├── baz.txt
│ ├── bleh.txt
│ └── foo.txt
└── two/
├── bar.txt
└── gaa.txt
When I add…
![](../../users/profiles/187907.webp)
sa125
- 25,703
- 36
- 105
- 149
20
votes
10 answers
Is there a workaround for Java's poor performance on walking huge directories?
I am trying to process files one at a time that are stored over a network. Reading the files is fast due to buffering is not the issue. The problem I have is just listing the directories in a folder. I have at least 10k files per folder over many…
![](../../users/profiles/21838.webp)
Pyrolistical
- 26,088
- 21
- 78
- 104
15
votes
2 answers
Can I make RecursiveDirectoryIterator skip unreadable directories?
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(".")) as $file) {
echo "$file\n";
}
Is there any way for this code to not throw UnexpectedValueException "failed to open dir: Permission denied" whenever there is a unreadable…
![](../../users/profiles/166921.webp)
Kamil Szot
- 15,477
- 6
- 53
- 62
10
votes
3 answers
Java library to return a List for glob or Ant-like pattern "*foo/**/*.txt"?
I'm looking for a lib which would provide a method which would give me a list of files matching given Ant-like pattern.
For *foo/**/*.txt I'd get
foo/x.txt
foo/bar/baz/.txt
myfoo/baz/boo/bar.txt
etc. I know it's achievable with DirWalker and…
![](../../users/profiles/145989.webp)
Ondra Žižka
- 36,997
- 35
- 184
- 250
9
votes
8 answers
unable to skip unreadable directories with RecursiveDirectoryIterator
I want to get a list of all the subdirectories and my below code works except when I have readonly permissions on certain folders.
In the below question it shows how to skip a directory with RecursiveDirectoryIterator
Can I make…
![](../../users/profiles/737114.webp)
ak85
- 3,626
- 16
- 56
- 107
8
votes
4 answers
A Python walker that can ignore directories
I need a file system walker that I could instruct to ignore traversing
directories that I want to leave untouched, including all subdirectories
below that branch.
The os.walk and os.path.walk just don't do it.
![](../../users/profiles/100171.webp)
Johan Carlsson
- 683
- 3
- 11
- 24
8
votes
5 answers
How to walk a directory in C
I am using glib in my application, and I see there are convenience wrappers in glib for C's remove, unlink and rmdir. But these only work on a single file or directory at a time.
As far as I can see, neither the C standard nor glib include any sort…
![](../../users/profiles/13468.webp)
mlibby
- 5,787
- 1
- 27
- 38
3
votes
3 answers
Recursively walk a LARGE directory using Scala 2.8 continuations
Is it possible to recursively walk a directory using Scala continuations (introduced in 2.8)?
My directory contains millions of files, so I cannot use a Stream because I will get an out-of-memory. I am trying to write an Actor dispatch to have…
![](../../users/profiles/96233.webp)
Ralph
- 29,142
- 31
- 124
- 261
3
votes
3 answers
URL tree walker in Python?
For URLs that show file trees, such as Pypi packages,
is there a small solid module to walk the URL tree and list it like ls -lR?
I gather (correct me) that there's no standard encoding of file attributes,
link types, size, date ... in html
![](../../users/profiles/86643.webp)
denis
- 18,805
- 6
- 56
- 79
3
votes
3 answers
Working with File Attributes in C# .Net 2.0
So how can i recursively search a Folder and un-hide ALL files and sub folders in a directory? Like have it check each file and each folder... if they're hidden.. un-hide them. Iv been messing around with it all morning with no luck... i got all…
![](../../users/profiles/356027.webp)
NightsEVil
- 499
- 2
- 13
- 21
3
votes
3 answers
In python exclude folders which start with underscore or more than six characters long
I want to store all the folder names except the folders which start with underscore (_) or have more than 6 characters.To get the list, i use this code
folders = [name for name in os.listdir(".") if os.path.isdir(name)]
What change do i need to…
![](../../users/profiles/2711080.webp)
Kneerudge
- 55
- 10
3
votes
3 answers
How to walk a directory over a local network using PHP?
How can i list the contents of a windows share using PHP?
$SearchFolder = "\\\\192.168.1.100\\pdfoutput\\";
if (is_dir($SearchFolder))
{
if ($Directory = opendir($SearchFolder))
{
while (($File = readdir($Directory)) !== false)
…
![](../../users/profiles/13227.webp)
Gary Willoughby
- 46,098
- 37
- 127
- 193
2
votes
1 answer
Visit only directories of a specific depth with Java 7
When using the method
java.nio.file.Files.walkFileTree(Path root, Set options, int maxDepth, FileVisitor visitor)
one can specify the maximum depth of files to visit. Is there also a way to specify that only paths of a specific, exact depth shall…
![](../../users/profiles/1523648.webp)
oberlies
- 10,674
- 2
- 54
- 98