Python Forum
scandir() recursively and return path + filename
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
scandir() recursively and return path + filename
#3
(May-09-2018, 01:12 AM)malonn Wrote: it returns all files within the directory and subdirectories. How can I modify it to return the files with their full paths?
It's easier to use os.walk(),which is recursive bye default.
Then just join root and files for full paths.
import os

for root,dirs,files in os.walk('D:\\App Back-Ups'):
    for file in files:
        print(os.path.join(root, file))
Reply


Messages In This Thread
RE: scandir() recursively and return path + filename - by snippsat - May-09-2018, 04:40 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Modifying a dictionary recursively SpongeB0B 2 290 May-12-2024, 04:09 PM
Last Post: Gribouillis
  How to return the next page from json recursively? sandson 0 1,232 Apr-01-2022, 11:01 PM
Last Post: sandson
  Help Needed | Read Outlook email Recursively & download attachment Vinci141 1 4,187 Jan-07-2022, 07:38 PM
Last Post: cubangt
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 2,282 Sep-09-2021, 01:25 PM
Last Post: Yoriz
Star Recursively convert nested dicts to dict subclass Alfalfa 1 2,985 Jan-22-2021, 05:43 AM
Last Post: buran
  Get the filename from a path 12237ee1 7 3,686 Jul-13-2020, 06:01 PM
Last Post: 12237ee1
  Python script that recursively zips folders WITHOUT nesting the folder inside the zip umkc1 1 2,976 Feb-11-2020, 09:12 PM
Last Post: michael1789
  How to get full path of specified hidden files matching pattern recursively SriRajesh 4 4,085 Jan-18-2020, 07:12 PM
Last Post: SriRajesh
  Find a given file recursively inside a directory alinaveed786 1 2,007 Jul-01-2019, 01:53 PM
Last Post: ichabod801
  Return all Path value from function Palerm0_24 2 2,616 Mar-18-2019, 03:09 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020