The function is dirname and not dirName (no camelcase N, done too much Java lately?)
If you had copy-pasted the code in the python-fu console, you would have found this very quickly:
➤> folderName = os.path.dirName(filePath)
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'module' object has no attribute 'dirName'
The method you point to in the Tutorials section to is not to be used in the python-fu console but in your code (it reroutes the stdOut and obviously the python-fu console needs it too...)
If you had copy-pasted the code in the python-fu console, you would have found this very quickly:
➤> folderName = os.path.dirName(filePath)
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'module' object has no attribute 'dirName'
The method you point to in the Tutorials section to is not to be used in the python-fu console but in your code (it reroutes the stdOut and obviously the python-fu console needs it too...)