AMA1.txtAMA2.txt
files=[]
for file in os.listdir(someDir):
if file.endswith(".txt"):
files.append(file)
convert = lambda text: int(text) if text.isdigit() else text
alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)',key) ]
files.sort( key=alphanum_key )
for i in files:
print (i)
I got so far, but missing the sorting :
func main() {
dirname := "someDir"
d, err := os.Open(dirname)
if err != nil {
fmt.Println(err)
}
defer d.Close()
fi, err := d.Readdir(-1)
if err != nil {
fmt.Println(err)
}
for _, fi := range fi {
if fi.Mode().IsRegular() {
fmt.Println(fi.Name())
}
}
}