We have a folder containing 1 sub-folder for every participant in a study. The subfolders are named with the participants' ID, e.g., 1000, 1001, 1002, 1003. Every participant folder contains a shapefile (and associated files) of the same name (e.g., 1000.shp, 1001.shp, etc). Each shapefile has several points.
We need to add a column called "PID" to every shapefile. Then we need to add the participant's ID (i.e., the file name, 1000, 1001, 1002) to every row.
For instance, in the folder "1000", there is a shapefile called "1000.shp". In the associated data table, we need to add a column called "PID". Then we need to insert the value "1000" for every row in this new PID column.
Is there a way to automate this process?
I work with ArcGIS, QGIS, and R. I use R extensively, but not for spatial work. That said, I might have an easier time understanding a programmatic approach in R if one exists.