Hm, didn't know about Pathdir extension.
Here's a solution by using the py (Python) extension. You point to the directory where the asc files are located, and then select just that file type ( modify the code from "txt"), and it walks through them. Seems to work for me.
extensions [py]
to setup
clear-all
user-message "Locate your asc file directory"
set-current-directory user-directory
;; Assumes the user will choose a directory
py:setup py:python
show py:runresult "1 + 1"
;; expect 2
py:run "print('hi')"
;; expect hi
;;
https://stackabuse.com/python-list-files-in-a-directory/py:run "import os"
(py:run
"for root, dirs, files in os.walk('.'):"
" x = files "
)
let z ( py:runresult "x" )
let filecount length(z)
print (word "Found " filecount " files in that directory: \n" z "\n\n")
let i -1;
repeat filecount [
set i (i + 1 )
;; decide whether file has the right suffix
let fname item i z
let fnamelength length(fname)
let suffix substring fname (fnamelength - 3) (fnamelength)
print (word "item " i " has suffix " suffix)
ifelse ( suffix = "txt" ) [process fname ] ;; or "asc",whatever
[ print (word ".......skipping over:" fname "\n\n" ) ] ;; skip not asc files
]
print "All done"
reset-ticks
end
to process [onefile]
print (word "......reading " onefile )
file-open onefile
print (word "First line: " file-read-line "\n\n")
file-close
end