Thanks a lot!
This is indeed simpler, but it is expecting a file as the input, and I need the user to select a directory instead (to be passed as a variable to the remaining script).
Yes, indeed. However, you can modify it. As you can see you can pull out the directory of the selected file with:
input$file$datapath[i]
and combine it with setwd() to select the directory. You can also save it as a variable for later use.
The loading .xlsx file was just an example.
Keep in mind that this will pass string looking like this ""C:\Users\kerth\AppData\Local\Temp\RtmpM3lf0r/ce50456e4c39ad7e7d4ac79a/0.xlsx"" so fo the directory you just need to detect the string and delete the filename. If you allow to select only one file then it can looks like this: