The path of least resistence to get this out of excel would be to copy and paste it into notepad then save its [something].vba. Then all you would need to do is just double click the vba file and your process would run. Outside of that you are going to have to pick a language, most likely VB.NET, and read up on Windows Forms and the System.IO namespace.
As for what the code is actually doing, that's a big long discussion with lots of links. If you really want to learn exactly what the script is doing, the meat and potatoes of the application is really the Scripting.FileSystemObject
] which is what is allowing you to traverse the directory.