Questions tagged [file-traversal]

13 questions
10
votes
9 answers

Looking for File Traversal Functions in Python that are Like Java's

In Java you can do File.listFiles() and receive all of the files in a directory. You can then easily recurse through directory trees. Is there an analogous way to do this in Python?
jjnguy
  • 136,852
  • 53
  • 295
  • 323
3
votes
2 answers

Implement sliding window on file lines in Python

I'm trying to implement a sliding/moving window approach on lines of a csv file using Python. Each line can have a column with a binary value yes or no. Basically, I want to rare yes noises. That means if say we have 3 yes lines in a window of 5…
Tina J
  • 4,983
  • 13
  • 59
  • 125
3
votes
4 answers

Reasonably faster way to traverse a directory tree in Python?

Assuming that the given directory tree is of reasonable size: say an open source project like Twisted or Python, what is the fastest way to traverse and iterate over the absolute path of all files/directories inside that directory? I want to do this…
Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187
2
votes
2 answers

Using ftw() properly in c

I have the following in my code: (Coding in c) ftw(argv[2], parseFile, 100) argv[2] is a local directory path. For instance. argv[2] = "TestCases" and there is a testcases folder in the same directory as my .o file. My understanding is that…
Brandon Amir
  • 380
  • 1
  • 6
  • 16
1
vote
2 answers

Call a method after ThreadPool.QueueUserWorkItem finished

I'm working on a console application written in c# The purpose of this app is to go through all drives and files and do something on them. But going through all files with a single thread is a time consuming process which is not my goal. So I…
0
votes
0 answers

How to resume from previous failed iteration while traversing through a big nested directory in Python?

I am currently using os.walk to navigate through all subfolders and files in a massive Network drive directory, However, Whenever my VPN disconnects, The for loop fails. Next day when I re-run my code, I would like to resume from the last file that…
0
votes
0 answers

Trying to check if the webdirectory is showing the same thing as index.html

I'm on a blackbox penetration training, last time i asked a question about sql injection which so far im making a progress on it i was able to retrieve the database and the column. This time i need to find the admin login, so i used dirsearch for…
0
votes
1 answer

os.listdir not accessing numerically labelled files in ascending order

We want the png files to be accessed as 15.png,45.png,75.png and so on. This is the code and the output we are getting import os keypts_labels=[] class_list=os.listdir('dataset') for name in class_list: for image in…
0
votes
2 answers

How do I copy this temporary char* variable into my struct for more permanent storage?

I'm trying to implement a thread pool, and I'm having quite the bit of trouble with getting the filepaths I'm supposed to work with to be more permanently stored than the temporary instance they're existing inside the OnOpen function from ftw. I'm…
Atryx10
  • 13
  • 3
0
votes
1 answer

Function replacement of nftw

ALL, According to this, ntfw is obsolete in POSIX.1-2008. Is there a replacement of this function? Or I should use something else across the board? TIA!
Igor
  • 5,620
  • 11
  • 51
  • 103
0
votes
2 answers

Using Java's file tree system to get only files and folders not subdirectories

So I have to use the Java file tree system because .listfiles files is for some reason incredibly slow going through a remote network. However all the Java file tree system examples list all the files in the subdirectories, severely slowing down the…
Brandan B
  • 464
  • 2
  • 6
  • 21
0
votes
1 answer

Callback on successful completion of recursion

I am following Folder Drag Drop for folder upload. function onDrop(e) { e.preventDefault(); e.stopPropagation(); var items = e.dataTransfer.items; for (var i=0; i
de-bugged
  • 935
  • 4
  • 14
  • 34
0
votes
2 answers

Python File Traversal

I am trying to create a function that takes in a the name of a root file then traverses through the directory and returns a list like this. [["folder1",[ ["subfolder1",[ "file1", "file2" ]], ["subfolder2",[ …
Abram I
  • 185
  • 2
  • 7