Finding files in a directory: glob: Revision history

From Master of Neuroscience Wiki

Diff selection: Mark the radio buttons of the revisions to compare and hit enter or the button at the bottom.
Legend: (cur) = difference with latest revision, (prev) = difference with preceding revision, m = minor edit.

17 October 2025

15 October 2025

  • curprev 13:2913:29, 15 October 2025 Davrot talk contribs 2,635 bytes +2,635 Created page with " == Goal == We want to deal with many files in a directory. What is an easy way to get the filename in a directory? Questions to [mailto:davrot@uni-bremen.de David Rotermund] == Creating test files == <syntaxhighlight lang="python">from pathlib import Path Path("Testfile_1.mat").touch() Path("Testfile_2.mat").touch() Path("Testfile_10.mat").touch() Path("Testfile_3.mat").touch()</syntaxhighlight> == Using glob in a for-loop == <syntaxhighlight lang="python">import gl..." Tag: Visual edit