os.walk Questions

4

Solved

I'm trying to use a python script to edit a large directory of .html files in a loop. I'm having trouble looping through the filenames using os.walk(). This chunk of code just turns the html files ...
Tubulate asked 30/5, 2014 at 23:24

2

Solved

I'm attempting to write a Python function that will recursively delete all empty directories. This means that if directory "a" contains only "b", "b" should be deleted, then "a" should be deleted (...
Mesquite asked 9/2, 2015 at 20:25

2

Solved

I have a path to a certain directory, and I need to get a list of all of it's sub-directories that themselves don't contain any sub-directories. For example, if I've got the following tree: -fath...
Hypercatalectic asked 7/4, 2014 at 17:49

2

I have huge set of files that I want to traverse through using python. I am using os.walk(source) for the same and is working but since I have a huge set of files it is taking too much and memory r...
Forefront asked 12/2, 2014 at 3:44

3

Solved

I just wrote a python script to get rid of some annoying suffixes in filenames, here's my code: import os for root, dirs, files in os.walk("path"): for filename in files: if filename.endswit...
Haemato asked 23/6, 2013 at 5:7

3

Solved

I'm trying to perform some geoprocessing. My task is to locate all shapefiles within a directory, and then find the full path name for that shapefile within the directory. I can get the name ...
Obeisance asked 9/5, 2013 at 15:25

4

Solved

Alright, I'm working with a Bioloid Premium humanoid robot, and Mac OS X will not recognize it. So I wrote a Python script to detect changes in my /dev/ folder because any connection on a Linux-bas...
Mawkish asked 1/3, 2013 at 14:0

1

Solved

I have such file structure: d:\temp\random1\index.html d:\temp\random2\index.html d:\temp\random3\index.html and I want to get paths to list in python. So the output would be: files = ['path':...
Porcelain asked 6/1, 2013 at 16:5

2

Solved

I am writing and testing code on XPsp3 w/ python 2.7. I am running the code on 2003 server w/ python 2.7. My dir structure will look something like this d:\ssptemp d:\ssptemp\ssp9-1 d:\ssptemp\ssp...
Webster asked 14/4, 2011 at 18:2

3

Solved

I'd like to recursively walk a directory, but I want python to break from any single listdir if it encounters a directory with greater than 100 files. Basically, I'm searching for a (.TXT) file, bu...
Alephnull asked 4/5, 2012 at 18:51

4

Solved

Perl has a lovely little utility called find2perl that will translate (quite faithfully) a command line for the Unix find utility into a Perl script to do the same. If you have a find command lik...
Horseshoe asked 24/9, 2011 at 20:56

4

Solved

Possible Duplicate: How to join two generators in Python? Is there a way in python to use os.walk to traverse multiple directories at once? my_paths = [] path1 = '/path/to/directory/...
Lackluster asked 28/9, 2011 at 19:36

2

I'd like to get a list of files that apply to a regex that i have. I guess i should use os.walk, but how can i use it with regex? Thanks.
Tailpipe asked 9/1, 2011 at 13:53

2

Solved

I want to quickly bzip2 compress several hundred gigabytes of data using my 8 core , 16 GB ram workstation. Currently I am using a simple python script to compress a whole directory tree using bzip...
Meet asked 27/7, 2010 at 15:25

1

I have a script to report me about all files, in a directory, so that users will be required to erase them (it's a really badly managed cluster, w/o real superuser). When I run the script I get: OS...
Jan asked 7/9, 2010 at 16:42

10

Solved

I have a piece of code which I'm using to search for the executables of game files and returning the directories. I would really like to get some sort of progress indicator as to how far along os.w...
Physicalism asked 29/1, 2010 at 18:58

3

Solved

So I am trying to use os.walk() to generate an XML representation of a directory structure. I seem to be getting a ton of duplicates. It properly places directories within each other and files in t...
Barhorst asked 20/1, 2010 at 21:10

© 2022 - 2024 — McMap. All rights reserved.