SoFunction
Updated on 2025-03-01

nodejs recursive folder gets all file path instances

Read folder

('./')

Determine file type

(item).isDirectory()

Path stitching

(dir, item)

Package

function deepGetFile(dir) {
    let backList = []
    let list = (dir)

    for (let index in list) {
        let item = (dir, list[index])
        if ((item).isDirectory()) {
            backList = (deepGetFile(item))
        } else {
            (item)
        }
    }
    return backList
}

The above is the detailed content of obtaining all file path instances in the nodejs recursive folder. For more information about obtaining nodejs recursive folder paths, please pay attention to my other related articles!