Let’s say I have a starting point folder called scan_inside. In the folder there are lots of sub-folders and in those sub-folders there might be even more folders with some content.
I would like to scan through all the folders and insert a file uploadme.xml if there is an index.htm file found in the current destination. How can I achieve this?
Illustration:
Scanning…
-
scan_inside:
-
subfolder1
- style.css
- logo.png
- folder
- homepage.htm
- index.htm
- uploadme.xml (must be uploaded because an index.htm file was found)
-
subfolder2
- about.htm
- logo.png
-
subfolder3
- index.html
- uploadme.xml (must be uploaded because an index.htm file was found)
-
2
Answers
I have updated the code a bit. It seeks for .php files and uploads an uploadme.xml to the same path. Seems to work quite alright but there might be some mistakes, though.
First, you need recursion, then you can go through all of the files and try to capture the extension. After that, you can add a file to the array.
Usage