How can I get the path of all files with specific extension

SangGeol :

I tried to act like a question using the filepath.Wark function.

var paths []string
err := os.Chdir("C:\\")
if err != nil {
    return err
}
err = filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
    if err != nil {
        return err
    }
    if !info.IsDir() {
        matched, err := filepath.Match(extension /*"*.reg"*/, info.Name())
        if err != nil {
            return err
        }
        if matched {
            paths = append(paths, path)
        }
    }
    return nil
})
if err != nil {
    return err
}

41 reg files were found this way, but using the everything program, 103 reg files were found.

I want to have 103 results. First of all, I checked that reg file exists not only in Program Files but also in the Users folder, but not found in go.

I ran admin permission.

stackoverflowusrone :

I would suggest using filepath.Ext to find the extension of the file, lowercase it and test equality with .reg. That would be a better way for just extensions.

Another reason could be that you might not have permissions to browse other users' directory in Users directory. Try running the program as administrator.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can i get all files on disk with a specific extension using 'Directory.getFiles' and save them in a list

How to get a list of all files with a specific extension?

How can I get all Class files in a specific package in Java?

Get all files with a specific extension

How can I recursively delete all files of a specific extension in the current directory?

How do i get a list of all files with a specific extension with c++ without <dirent.h> on windows

How can I retrieve a file path for file of a specific file extension?

How can I search within many files for a specific string and get returned the names of all files containing the string?

In cmd how can I list folders that contain files with a specific extension?

How can I remove files with a specific file extension in Rust

How to get all files list under specific path

How can I get history, with commit comments, for all changes for specific data range, specific directory path and specific branch

How can I delete all files with a particular extension in a particular folder?

How can I delete all files that have the same extension ".TMP"?

How can I get the file extension from a path?

How do I get all the files with a particular extension inside a directory?

How can I loop over all directories and subdirectories and find files with a specific extension, then run FFMPEG on them, then copy them to a new lib

How can I get all Files with a certain extension, without causing an IOException that tells me that the File I want to access is still in use

How to remove all files with specific extension in folder?

How can delete all files with a specific extension with cmd batch, excluding 2 specific words? Windows

How do I locate all files that include specific word as part of name and end with specific extension?

How can I get all files in a directory skipping unauthorized files?

How can I get jpg files path for javascprit

How do I list all files with a specific extension in my git repository?

How could I get the name of a specific file but not use the extension from a path?

How can I get all values from a specific key in mongoose?

How can i get specific file name from all subdirectotires?

how can i get the sum of all orders for a specific seller?

How can i remove all edges of a specific path(for example the shortest path between two nodes) in a graph?