Let
my_dir = "/raid/user/my_dir"
be a folder on my filesystem, which is not the current folder (i.e., it's not the result of os.getcwd()
). I want to retrieve the absolute paths of all files at the first level of hierarchy in my_dir
(i.e., the absolute paths of all files which are in my_dir
, but not in a subfolder of my_dir
) as a list of strings absolute_paths
. I need it, in order to later delete those files with os.remove()
.
This is nearly the same use case as
Get absolute paths of all files in a directory
but the difference is that I don't want to traverse the folder hierarchy: I only need the files at the first level of hierarchy (at depth 0? not sure about terminology here).