I tried to use PHP to read my folder and the subfolder to create a basic menu for me to use, but I noticed when I did that it took some time because it has to run it every time I go to the page.
Then I was thinking, why not use bash and make it create a text file that PHP can read and make it run every night with crontab? So I searched and tried but it was not so easy.
With this code I can get ONE subfolder
for D in /var/www/html/lib/*; do
if [ -d "${D}" ]; then
echo "${D}"
fi
done
it gave me
/var/www/html/lib/folder1
/var/www/html/lib/folder2
/var/www/html/lib/folder3
...
But the folders all have subfolders like
/var/html/lib/folder1/1990
...
My idea was to make a loop and then use
myfolder= "${D}"
addresstoremove="var/www/html/"
printf '%s\n' "${myfolder//$addresstoremove/}" >> textfile.txt
so it remove the address I do not need in my PHP code
find
. More on stackoverflow.com/a/1767402/5456794/var/html/lib/folder1/1990
a subfolder of/var/www/html/lib/folder1
? The path is definitely different.